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

我正在尝试基于示例here为AWS Cloudfront生成签名的URL.在线

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

我得到错误UnsupportedAlgorithm:此后端不支持此密钥序列化.完整的跟踪如下:

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包.

上一篇:python – 未知的服务错误botocore


下一篇:python – 如何在给定主分区键值列表的情况下一次批量调用多个项目