使用wincertstore提取需要私钥的客户端证书

时间:2020-10-13 11:28:01

标签: python python-3.x windows client-certificates

使用wincertstore,我可以为Windows上的用户提取509证书。当我将此证书传递到request.get / post时,由于没有key文件,因此我获得了无效的证书。如何从用户的证书存储中提取key

这是解决的问题的一半,我只是不知道如何制作key文件:

import wincertstore
store = wincertstore.CertSystemStore(storename)
for cert in store.itercerts(usage=wincertstore.CLIENT_AUTH):
    if cert.get_name() == "xxx":
        cert_pem = cert.get_pem()
        file = open("esCertTest.pem", "w")
        file.write(cert_pem)
        file.close()

        return os.path.realpath(file.name)

欢迎任何帮助,我将头撞在墙上试图弄清楚。

0 个答案:

没有答案