I am looking for a way to extract the AuthorityKeyIdentifier extension from an X509Certificate2 instance. I did not see any built-in support for this but since windows can properly construct a certificate chain I know the functionality has to exist at some level. If the answer is to roll a DER parser, is there a good implementation that can be referenced?
I am looking for a way to extract the AuthorityKeyIdentifier extension from an X509Certificate2
Share
Iterate through the extensions in the X509Certificate2.Extensions property and look for an extension with the OID 2.5.29.35 (as per http://www.alvestrand.no/objectid/2.5.29.35.html). That is the AuthorityKeyIdentifier extension.
[Edit: Added the following.]
Each member of the Extensions property is an ASN encoded. So you can do the following to get it in a human readable or machine parsable format:
For one of the Microsoft intermediate CA certificates, it the Format() method returns the following:
It is certainly not easy to parse but you can look for a line starting with the regular expression
\[\d+\]Authority Info Accessthen find a line beneath it with the regular expressionURL=(.+)(the eight spaces are unclear in the formatting) and use the URL in the parenthesized group.