来自Google Developer Console的.p12文件出现PyCrypto错误 [英] PyCrypto Errors with .p12 file from Google Developer Console

查看:160
本文介绍了来自Google Developer Console的.p12文件出现PyCrypto错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在GAE Python中实现Google Identity Toolkit(gitkitv3)。用户在网站上登录后,出现以下错误:

  PyCrpto库不支持PKCS12格式。 '
NotImplementedError:PyCrpto库不支持PKCS12格式。尝试转换为PEM(openssl pkcs12 -in xxxxx.p12 -nodes -nocerts> privatekey.pem)或使用PyOpenSSL(如果本机代码是一个选项)。

基于一个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

现在,我收到以下错误消息:

 'PyCrypto库不支持X509证书。 '
NotImplementedError:PyCrypto库不支持X509证书。如果本机代码是一个选项,请尝试使用PyOpenSSL。

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




任何解决方法?

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




更新

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

解决方案

安装 pyopenssl

  pip install pyopenssl 


I am trying to implement Google Identity Toolkit (gitkitv3) in GAE Python. After a user signs in on the website, I get the following errors:

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

Based on a SO reply, I ran the following commands on my x.p12 file and used the generated privatekey.pem file instead:

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

Now, I am getting the following error:

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

I had downloaded the x.p12 from Google Developer Console. How to fix this error? Please help


ANY WORKAROUND?

Do I necessarily need this file .p12 file or can I copy its contents to a global variable and use it (as a workaround)? Could someone please explain me the actual use of this file?


UPDATE
Looks like PyCrypto library provided by Google is extremely limited and lacks capability to support X509.

解决方案

Installing pyopenssl fixed the issue for me:

pip install pyopenssl

这篇关于来自Google Developer Console的.p12文件出现PyCrypto错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆