From 0c0625f1cce4c1725fb3982d86374ec12fe572c2 Mon Sep 17 00:00:00 2001 From: Kevin Jones Date: Tue, 11 Jan 2022 17:21:44 -0500 Subject: [PATCH 1/2] Update SAN test to account for OpenSSL 3 changes. --- .../tests/TestUtilities/System/PlatformDetection.Unix.cs | 5 +++++ .../tests/AsnEncodedData.cs | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs index 99492706f7ec99..ba816d6cfe811f 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs @@ -55,6 +55,11 @@ public static partial class PlatformDetection GetOpenSslVersion() : throw new PlatformNotSupportedException(); + private static readonly Version s_openssl3Version = new Version(3, 0, 0); + public static bool IsOpenSsl3 => !IsOSXLike && !IsWindows && !IsAndroid ? + GetOpenSslVersion() >= s_openssl3Version : + false; + /// /// If gnulibc is available, returns the release, such as "stable". /// Otherwise returns "glibc_not_found". diff --git a/src/libraries/System.Security.Cryptography.Encoding/tests/AsnEncodedData.cs b/src/libraries/System.Security.Cryptography.Encoding/tests/AsnEncodedData.cs index 0f63a74998dd43..bb1b734a8e5311 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/tests/AsnEncodedData.cs +++ b/src/libraries/System.Security.Cryptography.Encoding/tests/AsnEncodedData.cs @@ -101,11 +101,12 @@ public static void TestSubjectAlternativeName_Unix() sanExtension); string s = asnData.Format(false); + bool isOpenSsl3 = PlatformDetection.IsOpenSsl3; string expected = string.Join( ", ", // Choice[0]: OtherName - "othername:", + isOpenSsl3 ? "othername: UPN::subjectupn1@example.org" : "othername:", // Choice[1]: Rfc822Name (EmailAddress) "email:sanemail1@example.org", // Choice[2]: DnsName @@ -123,7 +124,7 @@ public static void TestSubjectAlternativeName_Unix() // Choice[7]: IPAddress (IPv6) "IP Address:2001:DB8:AC10:FE01:0:0:0:0", // Choice[7]: IPAddress (unknown type) - "IP Address:", + isOpenSsl3 ? "IP Address:" : "IP Address:", // Choice[7]: IPAddress (IPv4, longer string) "IP Address:255.255.255.255", // Choice[7]: IPAddress (IPv4, medium string) From 8fdafcbd8e45d0f03845301a2e1cf9a5d0e50db6 Mon Sep 17 00:00:00 2001 From: Kevin Jones Date: Wed, 12 Jan 2022 14:52:37 +0000 Subject: [PATCH 2/2] Fix test for browser --- .../Common/tests/TestUtilities/System/PlatformDetection.Unix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs index ba816d6cfe811f..ccb9d51bd665aa 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs @@ -56,7 +56,7 @@ public static partial class PlatformDetection throw new PlatformNotSupportedException(); private static readonly Version s_openssl3Version = new Version(3, 0, 0); - public static bool IsOpenSsl3 => !IsOSXLike && !IsWindows && !IsAndroid ? + public static bool IsOpenSsl3 => !IsOSXLike && !IsWindows && !IsAndroid && !IsBrowser ? GetOpenSslVersion() >= s_openssl3Version : false;