Skip to content

Commit 53e23d2

Browse files
Handle OSSL 3.4 change to SAN:othername formatting
Co-authored-by: Jeremy Barton <[email protected]>
1 parent 6b4ff8d commit 53e23d2

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ public static partial class PlatformDetection
5050
throw new PlatformNotSupportedException();
5151

5252
private static readonly Version s_openssl3Version = new Version(3, 0, 0);
53-
public static bool IsOpenSsl3 => !IsApplePlatform && !IsWindows && !IsAndroid && !IsBrowser ?
54-
GetOpenSslVersion() >= s_openssl3Version :
55-
false;
53+
private static readonly Version s_openssl3_4Version = new Version(3, 4, 0);
54+
55+
public static bool IsOpenSsl3 => IsOpenSslVersionAtLeast(s_openssl3Version);
56+
public static bool IsOpenSsl3_4 => IsOpenSslVersionAtLeast(s_openssl3_4Version);
5657

5758
/// <summary>
5859
/// If gnulibc is available, returns the release, such as "stable".
@@ -139,6 +140,18 @@ private static Version GetOpenSslVersion()
139140
return s_opensslVersion;
140141
}
141142

143+
// The "IsOpenSsl" properties answer false on Apple, even if OpenSSL is present for lightup,
144+
// as they are answering the question "is OpenSSL the primary crypto provider".
145+
private static bool IsOpenSslVersionAtLeast(Version minVersion)
146+
{
147+
if (IsApplePlatform || IsWindows || IsAndroid || IsBrowser)
148+
{
149+
return false;
150+
}
151+
152+
return GetOpenSslVersion() >= minVersion;
153+
}
154+
142155
private static Version ToVersion(string versionString)
143156
{
144157
// In some distros/versions we cannot discover the distro version; return something valid.

src/libraries/System.Security.Cryptography/tests/AsnEncodedDataTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ public static void TestSubjectAlternativeName_Unix()
112112

113113
string s = asnData.Format(false);
114114
bool isOpenSsl3 = PlatformDetection.IsOpenSsl3;
115+
bool isOpenSsl3_4 = PlatformDetection.IsOpenSsl3_4;
115116

116117
string expected = string.Join(
117118
", ",
118119
// Choice[0]: OtherName
119-
isOpenSsl3 ? "othername: UPN::[email protected]" : "othername:<unsupported>",
120+
isOpenSsl3_4 ? "othername: UPN:[email protected]" :
121+
isOpenSsl3 ? "othername: UPN::[email protected]" : "othername:<unsupported>",
120122
// Choice[1]: Rfc822Name (EmailAddress)
121123
122124
// Choice[2]: DnsName

0 commit comments

Comments
 (0)