使用Google Developer Console中的.p12文件导致PyCrypto错误

gsi*_*nha 3 google-app-engine pycrypto oauth-2.0 oauth2client google-oauth

我正在尝试在GAE Python中实现Google Identity Toolkit(gitkitv3).用户登录网站后,我收到以下错误:

'PKCS12 format is not supported by the PyCrpto library. '
NotImplementedError: PKCS12 format is not supported by the PyCrpto library. Try converting to a "PEM" (openssl pkcs12 -in xxxxx.p12 -nodes -nocerts > privatekey.pem) or using PyOpenSSL if native code is an option.
Run Code Online (Sandbox Code Playgroud)

基于SO回复,我在x.p12文件上运行以下命令,并使用生成的privatekey.pem文件:

openssl pkcs12 -passin pass:notasecret -in x.p12 -nocerts -passout pass:notasecret -out key.pem 
openssl pkcs8 -nocrypt -in key.pem -passin pass:notasecret -topk8 -out privatekey.pem
Run Code Online (Sandbox Code Playgroud)

现在,我收到以下错误:

'X509 certs are not supported by the PyCrypto library. '
NotImplementedError: X509 certs are not supported by the PyCrypto library. Try using PyOpenSSL if native code is an option.
Run Code Online (Sandbox Code Playgroud)

我从Google Developer Console下载了x.p12.如何解决这个错误?请帮忙


有什么办法吗?

我是否一定需要此文件.p12文件,还是可以将其内容复制到全局变量并使用它(作为变通方法)?有人可以解释一下这个文件的实际用途吗?


更新
看起来Google提供的PyCrypto库非常有限,缺乏支持X509的能力.

Sus*_*hil 8

安装pyopenssl修复了我的问题:

pip install pyopenssl
Run Code Online (Sandbox Code Playgroud)