Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e49a617

Browse files
bartonjsdanmoseley
authored andcommitted
React to X509Chain changes in macOS 10.13.4 (#28673)
10.13.4 changed some of the detail codes for building the X509ChainStatusFlag values. "ValidLeaf" (etc) => "TemporalValidity" "WeakLeaf" (etc) => "WeakKeySize" new "MissingIntermediate" when the chain didn't complete instead of "AnchorTrusted" lower down.
1 parent 2a7568d commit e49a617

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/Native/Unix/System.Security.Cryptography.Native.Apple/pal_x509chain.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ static void MergeStatusCodes(CFTypeRef key, CFTypeRef value, void* context)
154154
CFStringRef keyString = reinterpret_cast<CFStringRef>(key);
155155

156156
if (CFEqual(keyString, CFSTR("NotValidBefore")) || CFEqual(keyString, CFSTR("ValidLeaf")) ||
157-
CFEqual(keyString, CFSTR("ValidIntermediates")) || CFEqual(keyString, CFSTR("ValidRoot")))
157+
CFEqual(keyString, CFSTR("ValidIntermediates")) || CFEqual(keyString, CFSTR("ValidRoot")) ||
158+
CFEqual(keyString, CFSTR("TemporalValidity")))
158159
*pStatus |= PAL_X509ChainNotTimeValid;
159160
else if (CFEqual(keyString, CFSTR("Revocation")))
160161
*pStatus |= PAL_X509ChainRevoked;
@@ -168,8 +169,10 @@ static void MergeStatusCodes(CFTypeRef key, CFTypeRef value, void* context)
168169
*pStatus |= PAL_X509ChainExplicitDistrust;
169170
else if (CFEqual(keyString, CFSTR("RevocationResponseRequired")))
170171
*pStatus |= PAL_X509ChainRevocationStatusUnknown;
172+
else if (CFEqual(keyString, CFSTR("MissingIntermediate")))
173+
*pStatus |= PAL_X509ChainPartialChain;
171174
else if (CFEqual(keyString, CFSTR("WeakLeaf")) || CFEqual(keyString, CFSTR("WeakIntermediates")) ||
172-
CFEqual(keyString, CFSTR("WeakRoot")))
175+
CFEqual(keyString, CFSTR("WeakRoot")) || CFEqual(keyString, CFSTR("WeakKeySize")))
173176
{
174177
// Because we won't report this out of a chain built by .NET on Windows,
175178
// don't report it here.

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,12 @@ public static void InvalidSelfSignedSignature()
642642
}
643643
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
644644
{
645-
expectedFlags = X509ChainStatusFlags.UntrustedRoot;
645+
// For OSX alone expectedFlags here means OR instead of AND.
646+
// Because the error code changed in 10.13.4 from UntrustedRoot to PartialChain
647+
// and we handle that later in this test.
648+
expectedFlags =
649+
X509ChainStatusFlags.UntrustedRoot |
650+
X509ChainStatusFlags.PartialChain;
646651
}
647652
else
648653
{
@@ -670,6 +675,18 @@ public static void InvalidSelfSignedSignature()
670675
X509ChainStatusFlags.NoError,
671676
(a, b) => a | b);
672677

678+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
679+
{
680+
// If we're on 10.13.3 or older we get UntrustedRoot.
681+
// If we're on 10.13.4 or newer we get PartialChain.
682+
//
683+
// So make the expectedValue be whichever of those two is set.
684+
expectedFlags = (expectedFlags & allFlags);
685+
// One of them has to be set.
686+
Assert.NotEqual(X509ChainStatusFlags.NoError, expectedFlags);
687+
// Continue executing now to ensure that no other unexpected flags were set.
688+
}
689+
673690
Assert.Equal(expectedFlags, allFlags);
674691
}
675692
}

0 commit comments

Comments
 (0)