Skip to content

Commit f53ffe6

Browse files
authored
Fix X.509 tests on macOS 26 beta 6
Apple made a few changes to their trust stores in macOS 26 beta 6. The first, BuildChainForCertificateSignedWithDisallowedKey is they no longer have a list of disallowed keys. Prior to macOS 26, Apple kept a list of blocked keys at /System/Library/Security/Certificates.bundle/Contents/Resources/Blocked.plist. These values in the plist were SHA-1 subjectKeyIdentifiers. This list is no longer present on macOS 26. This seems largely sensible - all of those certificates that had those subject key identifiers are distrusted by other means, such as expiration or simply no longer being present in the root store. The second, SystemTrustCertificateWithCustomRootTrust, is failing because Apple yanked an expired root from their trust store. So it's going in to the same logical path as OpenSSL is now.
1 parent a077234 commit f53ffe6

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static partial class PlatformDetection
4444
public static bool IsNotMacOsAppleSilicon => !IsMacOsAppleSilicon;
4545
public static bool IsAppSandbox => Environment.GetEnvironmentVariable("APP_SANDBOX_CONTAINER_ID") != null;
4646
public static bool IsNotAppSandbox => !IsAppSandbox;
47+
public static bool IsApplePlatform26OrLater => IsApplePlatform && Environment.OSVersion.Version.Major >= 26;
4748

4849
public static Version OpenSslVersion => !IsApplePlatform && !IsWindows && !IsAndroid ?
4950
GetOpenSslVersion() :

src/libraries/System.Security.Cryptography/tests/X509Certificates/ChainTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,13 @@ public static void SystemTrustCertificateWithCustomRootTrust(bool addCertificate
288288

289289
// Check some known conditions.
290290

291-
if (PlatformDetection.UsesAppleCrypto)
291+
if (OperatingSystem.IsLinux() || PlatformDetection.IsApplePlatform26OrLater)
292292
{
293-
Assert.Equal(3, chain.ChainElements.Count);
293+
Assert.Equal(2, chain.ChainElements.Count);
294294
}
295-
else if (OperatingSystem.IsLinux())
295+
else if (PlatformDetection.IsApplePlatform)
296296
{
297-
Assert.Equal(2, chain.ChainElements.Count);
297+
Assert.Equal(3, chain.ChainElements.Count);
298298
}
299299
}
300300
}
@@ -1112,7 +1112,6 @@ public static void BuildChainForFraudulentCertificate()
11121112
}
11131113

11141114
[Fact]
1115-
[SkipOnPlatform(TestPlatforms.Linux, "Not supported on Linux.")]
11161115
public static void BuildChainForCertificateSignedWithDisallowedKey()
11171116
{
11181117
// The intermediate certificate is from the now defunct CA DigiNotar.
@@ -1178,12 +1177,13 @@ public static void BuildChainForCertificateSignedWithDisallowedKey()
11781177
chain.ChainPolicy.ExtraStore.Add(intermediateCert);
11791178
Assert.False(chain.Build(cert));
11801179

1181-
if (PlatformDetection.IsAndroid)
1180+
if (PlatformDetection.IsAndroid || PlatformDetection.IsApplePlatform26OrLater || PlatformDetection.IsLinux)
11821181
{
11831182
// Android always validates trust as part of building a path,
11841183
// so violations comes back as PartialChain with no elements
1184+
// Apple 26 no longer block these SKIs since the roots are no longer trusted at all and are expired.
1185+
// Linux has no concept of a blocked key list, they just remove certificates from a trust store.
11851186
Assert.Equal(X509ChainStatusFlags.PartialChain, chain.AllStatusFlags());
1186-
Assert.Equal(0, chain.ChainElements.Count);
11871187
}
11881188
else
11891189
{

0 commit comments

Comments
 (0)