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 convertpCrlInfopointer ofCRL_CONTEXTstructure toCRL_INFOstructure.rgCRLEntryis an array of pointers (array size is determined bycCRLEntrymember ofCRL_INFO).CRL_ENTRYstructure.SerialNumbermember ofCRL_ENTRYis 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_CONTEXTstructure by calling CertFreeCRLContext function when finished to prevent memory leaks.