gpt4 book ai didi

python-3.x - 从 PKS 文件中获取 python signxml 的证书和 key

转载 作者:行者123 更新时间:2023-12-01 01:42:46 44 4
gpt4 key购买 nike

我使用以下命令从 pks 文件中获取证书和 key 。

 openssl pkcs12 -in ../my.pfx  -nocerts -out my.key
openssl pkcs12 -in ~/my.pfx -clcerts -nokeys -out cert.pem

但是我不断收到错误。我怀疑 my.key 是不正确的。如何生成正确的 key 和证书来提供 signxml?我在 Ubuntu 16.04 上使用 python3.5。先感谢您!
 File "/home/ubuntu/.local/lib/python3.5/site-packages/signxml/__init__.py", line 362, in sign
key = load_pem_private_key(key, password=passphrase, backend=default_backend())
File "/home/ubuntu/.local/lib/python3.5/site-packages/cryptography/hazmat/primitives/serialization/base.py", line 16, in load_pem_private_key
return backend.load_pem_private_key(data, password)
File "/home/ubuntu/.local/lib/python3.5/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1025, in load_pem_private_key
password,
File "/home/ubuntu/.local/lib/python3.5/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1218, in _load_key
mem_bio = self._bytes_to_bio(data)
File "/home/ubuntu/.local/lib/python3.5/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 454, in _bytes_to_bio
data_ptr = self._ffi.from_buffer(data)
TypeError: from_buffer() cannot return the address of a unicode object

来自 xml 页面的示例代码:
cert = open("example.pem").read()
key = open("example.key").read()
root = ElementTree.fromstring(data_to_sign)
signed_root = XMLSigner().sign(root, key=key, cert=cert)
verified_data = XMLVerifier().verify(signed_root).signed_xml

最佳答案

我想这是 Python2 vs Python3 的事情。我需要的只是

key = open("example.key").read().encode('ascii')

关于python-3.x - 从 PKS 文件中获取 python signxml 的证书和 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54729483/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com