Skip to content

Commit 9541e96

Browse files
vcsjonesbartonjs
andauthored
Handle OSSL 3.4 change to SAN:othername formatting
Co-authored-by: Jeremy Barton <[email protected]>
1 parent 64c2e18 commit 9541e96

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

5959
private static readonly Version s_openssl3Version = new Version(3, 0, 0);
60-
public static bool IsOpenSsl3 => !IsOSXLike && !IsWindows && !IsAndroid && !IsBrowser ?
61-
GetOpenSslVersion() >= s_openssl3Version :
62-
false;
60+
private static readonly Version s_openssl3_4Version = new Version(3, 4, 0);
61+
62+
public static bool IsOpenSsl3 => IsOpenSslVersionAtLeast(s_openssl3Version);
63+
public static bool IsOpenSsl3_4 => IsOpenSslVersionAtLeast(s_openssl3_4Version);
6364

6465
/// <summary>
6566
/// If gnulibc is available, returns the release, such as "stable".
@@ -146,6 +147,18 @@ private static Version GetOpenSslVersion()
146147
return s_opensslVersion;
147148
}
148149

150+
// The "IsOpenSsl" properties answer false on Apple, even if OpenSSL is present for lightup,
151+
// as they are answering the question "is OpenSSL the primary crypto provider".
152+
private static bool IsOpenSslVersionAtLeast(Version minVersion)
153+
{
154+
if (IsOSXLike || IsWindows || IsAndroid || IsBrowser)
155+
{
156+
return false;
157+
}
158+
159+
return GetOpenSslVersion() >= minVersion;
160+
}
161+
149162
private static Version ToVersion(string versionString)
150163
{
151164
// 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)