簡體   English   中英

UnsupportedAlgorithm:此后端不支持此密鑰序列化。 - Python加密技術load_pem_private_key

[英]UnsupportedAlgorithm: This backend does not support this key serialization. - Python cryptography load_pem_private_key

我正在嘗試根據此處的示例為AWS Cloudfront生成簽名的URL。 在線上

private_key = serialization.load_pem_private_key(
        key_file.read(),
        password=None,
        backend=default_backend()
    )

我得到錯誤UnsupportedAlgorithm: This backend does not support this key serialization. 完整的跟蹤如下:

File "command_util.py", line 98, in rsa_signer
    backend=default_backend()  
File "runtime/cryptography/hazmat/primitives/serialization.py", line 20, in load_pem_private_key
    return backend.load_pem_private_key(data, password)
File "runtime/cryptography/hazmat/backends/multibackend.py", line 286, in load_pem_private_key
    _Reasons.UNSUPPORTED_SERIALIZATION
UnsupportedAlgorithm: This backend does not support this key serialization.

在閱讀文檔時,它說由於以下原因而發生異常:

cryptography.exceptions.UnsupportedAlgorithm – the serialized key is of a type that is not supported by the backend or if 
the key is encrypted with a symmetric cipher that is not supported by the backend.

給出的PEM文件以-----BEGIN RSA PRIVATE KEY-----開頭,以-----END RSA PRIVATE KEY-----

我在開發此應用程序時使用谷歌appengine sdk。

我需要幫助理解此錯誤消息以及如何使其工作。

不幸的是,python加密庫不能與google appengine(GAE)一起使用,因為這個庫需要有C擴展,你不能在GAE中安裝C擴展。 您只能使用純python包。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM