I'm trying to validate a certificate chain in .NET (4.5.2) with X509Chain, and my chain will not validate because the leaf certificate has a critical extension (Apple Pay) that is not recognised by, presumably, the underlying security engine that Windows provides the .NET framework.
Currently I can work around this by ensuring that the only errors with the certificate chain are the errors that seem to be caused by this extension:
- one item in the leaf's
ChainElementStatuswithStatusofX509ChainStatusFlags.InvalidExtension - one item in the leaf's
ChainElementStatuswithStatusof(X509ChainStatusFlags)0x08000000(amusingly the IDE gives this the nameHasNotSupportedCriticalExtensionbut that value doesn't exist in the enum; I assume this is due to .NET framework changes) - that the leaf does have a
Criticalextension with the expected OID
This seems messy, though. I would far rather tell the framework to expect this extension upfront than to verify that it failed for the correct reasons.
I've found this question on how to achieve this with BouncyCastle (although it involves changing the source) but can't find a way to do this with the built-in X509Chain class.
I also can't find a way to "install" this extension into Windows to make it recognise it.
Is there a way to do this? Or is either stripping the extension or making the framework recognise it a worse "bad idea" than letting it fail and verifying exactly why it did?