简体   繁体   English

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

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

I am trying to generate signed urls for AWS Cloudfront based on the example here . 我正在尝试根据此处的示例为AWS Cloudfront生成签名的URL。 On the line 在线上

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

I get the error UnsupportedAlgorithm: This backend does not support this key serialization. 我得到错误UnsupportedAlgorithm: This backend does not support this key serialization. The full trace is as below: 完整的跟踪如下:

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.

On reading the docs it says that the exception occurs because of the following: 在阅读文档时,它说由于以下原因而发生异常:

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.

The PEM file given starts with -----BEGIN RSA PRIVATE KEY----- and ends with -----END RSA PRIVATE KEY----- . 给出的PEM文件以-----BEGIN RSA PRIVATE KEY-----开头,以-----END RSA PRIVATE KEY-----

I am using google appengine sdk while developing this application. 我在开发此应用程序时使用谷歌appengine sdk。

I need help understanding this error message and how to make this work. 我需要帮助理解此错误消息以及如何使其工作。

Unfortunately the python cryptography library cannot be used with google appengine(GAE) as this library needs to have C extensions and you cannot install C extensions in GAE. 不幸的是,python加密库不能与google appengine(GAE)一起使用,因为这个库需要有C扩展,你不能在GAE中安装C扩展。 You can only use pure python packages. 您只能使用纯python包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM