Python无法对xml数据进行unserialize错误

2024-03-29 08:15:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试Python的signxml库来对xml进行签名并验证签名。 但它抛出了以下异常,可能是什么错误?在

Traceback (most recent call last):
  File "C:/Users/digz/Documents/test_signxml/xml_verify_test_4.py", line 24, in <module>
    signed_root = XMLSigner().sign(root, key=key, cert=cert)
  File "C:\Python27\lib\site-packages\signxml\__init__.py", line 364, in sign
    key = load_pem_private_key(key, password=passphrase, backend=default_backend())
  File "C:\Python27\lib\site-packages\cryptography\hazmat\primitives\serialization.py", line 20, in load_pem_private_key
    return backend.load_pem_private_key(data, password)
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\multibackend.py", line 289, in load_pem_private_key
    return b.load_pem_private_key(data, password)
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 1033, in load_pem_private_key
    password,
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 1202, in _load_key
    self._handle_key_loading_error()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 1274, in _handle_key_loading_error
    raise ValueError("Could not unserialize key data.")
ValueError: Could not unserialize key data.

下面是我使用的代码:

^{pr2}$

Tags: keyinpybackendlibpackageslinesite