0

I have created a public/private key pair with openSSL and converted it into a *.pfx file with openSSL. I then imported this file into the Windows Trusted Certificate Store.

I now would like to access the private key from this certificate via c++ code. Is this possible? If yes, can you please point me into a direction? I haven't found anything suitable yet.

jww
  • 97,681
  • 90
  • 411
  • 885
user3079834
  • 2,009
  • 2
  • 31
  • 63
  • Lots of reading: https://msdn.microsoft.com/en-us/library/windows/desktop/aa380255(v=vs.85).aspx _"CryptoAPI is intended for use by developers of Windows-based applications that will enable users to create and exchange documents and other data in a secure environment, especially over nonsecure media such as the Internet. Developers should be familiar with the C and C++ programming languages and the Windows programming environment. Although not required, an understanding of cryptography or security-related subjects is advised."_ – Richard Critten Jan 03 '18 at 16:06

1 Answers1

1

Yes it is possible to access the private key.

CertEnumCertificatesInStore returns PCCERT_CONTEXT structure which contain the encoded and decoded representations of certificates. Passing this structure to the CryptAcquireCertificatePrivateKey obtains the private key from the certificate

rahul k
  • 31
  • 4