【发布时间】:2019-11-04 06:58:40
【问题描述】:
我正在使用 pyopenssl lib,我想使用他们的 crypto.PKCS12 对象 api 生成一个 p12 文件。
所以这个证书值是从 API 获得的,并保存在一个文件中,如下所示:
echo -e "-----cert text with begin & end-----" > cert.crt
它创建了文件,当我在命令下运行时,有一个正确的输出,即使我在线验证它,它也显示一切正常:
openssl x509 -in cert.crt -text -noout
现在的问题是当使用下面将证书设置为 PKCS12 对象时,它给出了一个错误:
from OpenSSL import crypto
p12 = crypto.PKCS12()
p12.set_certificate("/home/someuser/Documents/path/to/cert.crt")
然后它会抛出一个错误:
文件 "/home/someuser/.local/lib/python3.6/site-packages/OpenSSL/crypto.py", 第 2429 行,在 set_certificate 中 raise TypeError("cert must be an X509 instance")
我不明白为什么 lib 抱怨证书。我在这里有什么遗漏吗?
【问题讨论】:
标签: python python-3.x openssl x509certificate pyopenssl