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

十年热恋 提交于 2019-12-10 15:22:44

问题


I am trying to generate signed urls for AWS Cloudfront based on the example here. 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. 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----- .

I am using google appengine sdk while developing this application.

I need help understanding this error message and how to make this work.


回答1:


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. You can only use pure python packages.



来源:https://stackoverflow.com/questions/39251810/unsupportedalgorithm-this-backend-does-not-support-this-key-serialization-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!