4

我正在尝试根据此处的示例为 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-----

我在开发此应用程序时使用 google appengine sdk。

我需要帮助理解此错误消息以及如何使其工作。

4

1 回答 1

2

不幸的是,python 加密库不能与 google appengine(GAE) 一起使用,因为该库需要具有 C 扩展,并且您不能在 GAE 中安装 C 扩展。您只能使用纯 python 包。

于 2016-09-01T09:47:52.287 回答