endesive icon indicating copy to clipboard operation
endesive copied to clipboard

how can i sign with instance of a certificate from windows store?

Open Fulea-Andrei opened this issue 3 years ago • 4 comments

hello, i want to sign with your library using a file from win cert sign, not from exported on local. can you help me please with the code or some indications about type of the variable wanted?

Fulea-Andrei avatar Aug 12 '22 12:08 Fulea-Andrei

what do you mean by "file from win cert sign"?

m32 avatar Aug 12 '22 12:08 m32

thank you for the response. well, i mean windows certification store :) search - > run - > mmc - > certifications https://blog.darrenjrobinson.com/accessing-the-windows-certificate-store-using-python/ with the code from this blog, I m accesing all the certifications from a computer, and I want to sign documents with them.

Fulea-Andrei avatar Aug 12 '22 12:08 Fulea-Andrei

+++ your library example cms-signed.py is showing me how to sign a local file ( which can be an exported version from windows certificate store). I see how you are reading and passing that file, but I dont know how to pass the variable obtained from windows certificate store. I hope i was clear, I really need to fix this thing. thank you

Fulea-Andrei avatar Aug 12 '22 12:08 Fulea-Andrei

The windows store does not have api compatible with PKCS11, so it is not possible to sign anything using the functions related to the private key saved in the windows store. The only solution is to write a wrapper compatible with PKCS11 (HSM) and compatible with the windows store or export the certificate and key to a PFX file and use as in the examples (PFX = P12)

I don't know how to operate the MMC console, I don't use it. Maybe python cryptography has the ability to sign with a key saved in the windows store.

m32 avatar Aug 12 '22 12:08 m32

see example in pdf-sign-cms-hsm-windows.py - after importing CA and USER 1 certificates into windows cert store

m32 avatar Sep 22 '22 23:09 m32