I've connected to a MS PKI Certificate Revocation List distribution point and obtained the CRL
What's the most straightforward way to extract the list of serial numbers from the CRL without using third party libraries?
I've connected to a MS PKI Certificate Revocation List distribution point and obtained the CRL
What's the most straightforward way to extract the list of serial numbers from the CRL without using third party libraries?
You will have to unroll the CRL by using unmanaged CryptoAPI functions (through p/invoke, of course). Generally, you will have to the following high-level step-by-step:
Marshal.PtrToStructure
.NET method to convertpCrlInfo
pointer ofCRL_CONTEXT
structure toCRL_INFO
structure.rgCRLEntry
is an array of pointers (array size is determined bycCRLEntry
member ofCRL_INFO
).CRL_ENTRY
structure.SerialNumber
member ofCRL_ENTRY
is a byte array. You can directly useMarshal.Copy(IntPtr, Byte[], Int32, Int32)
method to copy unmanaged array to managed. This will give you serial number. Repeat steps 4-5 for each CRL entry.Do not forget to release pointer to
CRL_CONTEXT
structure by calling CertFreeCRLContext function when finished to prevent memory leaks.