-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-System.SecurityuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
If you use X509Chain.Build on a certificate that has a critical extension that is not understood, a CryptographicException is thrown on macOS. (repros on master)
For example, attempting to build a chain on a certificate that contains the CT Precertificate Poison extension:
Sample code to reproduce:
using RSA key = RSA.Create();
CertificateRequest certReq = new CertificateRequest(
new X500DistinguishedName("CN=Cert"),
key,
HashAlgorithmName.SHA256,
RSASignaturePadding.Pkcs1);
certReq.CertificateExtensions.Add(new X509Extension(
new AsnEncodedData(new Oid("1.3.6.1.4.1.11129.2.4.3"), new byte[] { 5, 0 }), true
));
DateTimeOffset notBefore = DateTimeOffset.UtcNow.AddDays(-1);
DateTimeOffset notAfter = notBefore.AddDays(30);
using X509Certificate2 cert = certReq.CreateSelfSigned(notBefore, notAfter);
X509Chain chain = new X509Chain();
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
chain.Build(cert);On MacOS will result in
Unhandled exception. System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation.
at Internal.Cryptography.Pal.SecTrustChainPal.ParseResults(SafeX509ChainHandle chainHandle, X509RevocationMode revocationMode)
Running with a debug build gives us:
Unknown Chain Status: CriticalExtensions
I think we are missing a mapping of "CriticalExtensions" ➡️ X509ChainStatusFlags.HasNotSupportedCriticalExtension
Metadata
Metadata
Assignees
Labels
area-System.SecurityuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner