Re: Extracing X509 Certificate data from the Certificate Strore



This task is perhaps so easy that it appears to be difficult. You just need
to use one of the Cert* functions to obtain a CERT_CONTEXT for the
certificate (see wincrypt.h). The raw certificate that you want is in the
context's pbCertEncoded and cbCertEncoded fields.

"Frank Walker" <walker@xxxxxxxxxxx> wrote in message
news:eVflCwM$FHA.436@xxxxxxxxxxxxxxxxxxxxxxx
>I would like to use the crypto api to export a certificate from the
>certificate store, with the certificate containing only the public key. In
>other words, the private key would be stripped out. Does anybody have any
>examples on how to do this?
>
> Frank Walker
>
> ""Jeffrey Tan[MSFT]"" <v-jetan@xxxxxxxxxxxxxxxxxxxx> wrote in message
> news:lzoHFpW%23FHA.2616@xxxxxxxxxxxxxxxxxxxxxxxx
>> Hi Shankar ,
>>
>> Based on my understanding, you want to export certificate from the
>> certificate store programmatically.
>>
>> I think we can export the X.509 certificate from the store with
>> CertSerializeCertificateStoreElement API. The MSDN link below shows a
>> sample code snippet:
>> "Example C Program: Serializing Certificates"
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/seccrypto/s
>> ecurity/example_c_program_serializing_certificates.asp
>>
>> Hope this helps
>>
>> Best regards,
>> Jeffrey Tan
>> Microsoft Online Partner Support
>> Get Secure! - www.microsoft.com/security
>> This posting is provided "as is" with no warranties and confers no
>> rights.
>>
>
>


.