Skip to content

Commit cd7b2be

Browse files
committed
Allow macOS chain building to use network if revocation checking is online.
The DisableCertificateDownloads property on the chain policy controls all network activity when building a chain on macOS, not just AIA fetching. If set to true, the (default) revocation policy would fail because the network would be treated as unavailable. On macOS, as a work around, permit the network activity if revocation checking is explicitly enabled.
1 parent c9d1fd6 commit cd7b2be

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/ChainPal.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,12 @@ public static IChainPal BuildChain(
611611

612612
SecTrustChainPal chainPal = new SecTrustChainPal();
613613

614+
// The allowNetwork controls all network activity for macOS chain building.
615+
// There is no way to independently enable or disable online revocation checking
616+
// and AIA fetching. If the caller specifies they want Online revocation checking,
617+
// then we need to allow network operations (including AIA fetching.)
618+
bool revocationRequiresNetwork = revocationMode == X509RevocationMode.Online;
619+
614620
try
615621
{
616622
chainPal.OpenTrustHandle(
@@ -622,7 +628,7 @@ public static IChainPal BuildChain(
622628

623629
chainPal.Execute(
624630
verificationTime,
625-
!disableAia,
631+
allowNetwork: !disableAia || revocationRequiresNetwork,
626632
applicationPolicy,
627633
certificatePolicy,
628634
revocationFlag);

src/libraries/System.Security.Cryptography.X509Certificates/tests/RevocationTests/DynamicRevocationTests.cs

+22
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,28 @@ public static void RevokeEndEntity(PkiOptions pkiOptions)
139139
});
140140
}
141141

142+
[Theory]
143+
[MemberData(nameof(AllViableRevocation))]
144+
public static void RevokeLeafWithAiaFetchingDisabled(PkiOptions pkiOptions)
145+
{
146+
SimpleTest(
147+
pkiOptions,
148+
(root, intermediate, endEntity, holder, responder) =>
149+
{
150+
DateTimeOffset now = DateTimeOffset.UtcNow;
151+
intermediate.Revoke(endEntity, now);
152+
holder.Chain.ChainPolicy.VerificationTime = now.AddSeconds(1).UtcDateTime;
153+
holder.Chain.ChainPolicy.DisableCertificateDownloads = true;
154+
155+
SimpleRevocationBody(
156+
holder,
157+
endEntity,
158+
rootRevoked: false,
159+
issrRevoked: false,
160+
leafRevoked: true);
161+
});
162+
}
163+
142164
[Theory]
143165
[MemberData(nameof(AllViableRevocation))]
144166
[ActiveIssue("https://github.com/dotnet/runtime/issues/31249", TestPlatforms.OSX)]

0 commit comments

Comments
 (0)