I'm trying to load a private key file of a personal cert from a key file and 
load it like so:

SSL_CTX_use_PrivateKey_file(pSSLContext, privateKeyFile, SSL_FILETYPE_PEM)

However the certificate is in the Windows Certificate Store. I'm trying to 
write it out to a PEM file, but I'm not quite sure how to get the data that 
goes in between ----BEGIN PRIVATE KEY---- and -----END PRIVATE KEY-----.

For the certificate pem file I can just base64 encode pbCertEncoded from the 
CERT_CONTEXT, but not idea what to do for the private key. I've tried so many 
things but all are incorrect. I've exported the file from the MMC snap-in and 
used OpenSSL to convert it to a pem file and that works, but I have no idea how 
to get that info programmatically.

Any help would be appreciated.

Tom Fili
Software Engineer
Analytical Graphics Inc.

Reply via email to