TMS Cryptography Pack and Windows CertStore Certificate

Hi, could You make an example how to use certificate taken from Windows Cert Store by CertFindCertificateInStrore from WinCrypt API with the component from the framework?
Best regards
Piotrek

Hi,
I have just write a blog post about this example: https://www.cyberens.fr/from-windows-certificate-store-to-tms-cryptography-pack-tx509certificate-component/
Best regards,
Marion

Great, Thank You, I think it could be usefull to add is to the package :slight_smile:
All the best
Piotrek

Hi,
I use that procedure to take the certificate from the windows certificate store and it works well, but when the certificate is with private key it is not decoded and finally it is impossible to sign a document. Could You help (exchange the procedure) to take (if exists) the private key too?

Hi Piotr,
Your first question was to use CertFindCertificateInStore from WinCryptAPI with TMS CP. I wrote a post to do that and finally it is not useful?!
I can help but I need to know what you need exactly. Do you know the function from WinCryptAPI to extract certificate AND private key?
Best regards,
Marion

Hi, Marion. The idea is to sign a document by certificate from windows cert store. I know that certificate coud be with and without a private key. I have one with private key imported from pfx (pfx signing works well).Your's function take a certificate from cert store but without a private key also where the certificate have it. This is why finally document could not be signed. I set a private key manually by use a pfx, becouse I have it and then document is signed properly. Probably to get a private key I should use CryptAcquireCertificatePrivateKey and may be some more ... I could not find any sucessul working example or instruction how to do it in that case.

Hi Piotr,
How could I have guessed that you would have liked to sign with the certificate from your first question?
I will take a look when I have some time.
Marion

Thank you. It was obvious to me that since I sign the document using the TMS Cryptography Pack and the pfx certificate, I would like to take the certificate from the windows certificate store and sign a document in the same way, but sorry if it was unclear.