Skip to content

[release/8.0-staging] Handle OSSL 3.4 change to SAN:othername formatting #115367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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::[email protected]" : "othername:<unsupported>",
isOpenSsl3_4 ? "othername: UPN:[email protected]" :
isOpenSsl3 ? "othername: UPN::[email protected]" : "othername:<unsupported>",
// Choice[1]: Rfc822Name (EmailAddress)
"email:[email protected]",
// Choice[2]: DnsName
Expand Down
Loading