Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ 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 && !IsBrowser ?
GetOpenSslVersion() >= s_openssl3Version :
false;
private static readonly Version s_openssl3_4Version = new Version(3, 4, 0);

public static bool IsOpenSsl3 => IsOpenSslVersionAtLeast(s_openssl3Version);
public static bool IsOpenSsl3_4 => IsOpenSslVersionAtLeast(s_openssl3_4Version);

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

// The "IsOpenSsl" properties answer false on Apple, even if OpenSSL is present for lightup,
// as they are answering the question "is OpenSSL the primary crypto provider".
private static bool IsOpenSslVersionAtLeast(Version minVersion)
{
if (IsOSXLike || IsWindows || IsAndroid || IsBrowser)
{
return false;
}

return GetOpenSslVersion() >= minVersion;
}

private static Version ToVersion(string versionString)
{
// In some distros/versions we cannot discover the distro version; return something valid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ public static void TestSubjectAlternativeName_Unix()

string s = asnData.Format(false);
bool isOpenSsl3 = PlatformDetection.IsOpenSsl3;
bool isOpenSsl3_4 = PlatformDetection.IsOpenSsl3_4;

string expected = string.Join(
", ",
// Choice[0]: OtherName
isOpenSsl3 ? "othername: UPN::subjectupn1@example.org" : "othername:<unsupported>",
isOpenSsl3_4 ? "othername: UPN:subjectupn1@example.org" :
isOpenSsl3 ? "othername: UPN::subjectupn1@example.org" : "othername:<unsupported>",
// Choice[1]: Rfc822Name (EmailAddress)
"email:sanemail1@example.org",
// Choice[2]: DnsName
Expand Down
Loading