Skip to content

Commit a40f92e

Browse files
authored
Handle OSSL 3.4 change to SAN:othername formatting
1 parent 1084c54 commit a40f92e

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
@@ -51,9 +51,10 @@ public static partial class PlatformDetection
5151
throw new PlatformNotSupportedException();
5252

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

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

144+
// The "IsOpenSsl" properties answer false on Apple, even if OpenSSL is present for lightup,
145+
// as they are answering the question "is OpenSSL the primary crypto provider".
146+
private static bool IsOpenSslVersionAtLeast(Version minVersion)
147+
{
148+
if (IsApplePlatform || IsWindows || IsAndroid || IsBrowser)
149+
{
150+
return false;
151+
}
152+
153+
return GetOpenSslVersion() >= minVersion;
154+
}
155+
143156
private static Version ToVersion(string versionString)
144157
{
145158
// 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::subjectupn1@example.org" : "othername:<unsupported>",
120+
isOpenSsl3_4 ? "othername: UPN:subjectupn1@example.org" :
121+
isOpenSsl3 ? "othername: UPN::subjectupn1@example.org" : "othername:<unsupported>",
120122
// Choice[1]: Rfc822Name (EmailAddress)
121123
"email:sanemail1@example.org",
122124
// Choice[2]: DnsName

0 commit comments

Comments
 (0)