gpt4 book ai didi

google-app-engine - AppEngine 上的 SignedJwtAssertionCredentials 无法识别 PEM key

转载 作者:太空宇宙 更新时间:2023-11-03 15:19:28 24 4
gpt4 key购买 nike

appengine 上的 SignedJwtAssertionCredentials(使用 pycrypto 2.6)不支持 PKCS12 格式,因此我尝试使用 PEM key 来代替,就像到处都建议的那样。

这是我的代码:

  f = file(os.path.join(os.path.dirname(__file__), KEY_FILE), "r")
key = f.read()
f.close()

credentials = SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key,
scope="https://www.googleapis.com/auth/drive"
http = httplib2.Http()
http = credentials.authorize(http)

KEY_FILE 是 PEM key ,使用以下命令转换:

openssl pkcs12 -in privatekey.p12 -nodes -nocerts > privatekey.pem

但我仍然收到此错误,好像它没有识别出这是一个 PEM key :

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.

如果我只将文件名传递给构造函数(而不读取文件的内容),同样的错误

有什么想法吗?

最佳答案

是的,这个错误具有很大的误导性。你在做什么很好;只需从 PEM 文件中删除 header ,使其以 -----BEGIN PRIVATE KEY----- 开头,或对其运行以下命令:

openssl pkcs8 -nocrypt -in privatekey.pem -passin pass:notasecret -topk8 -out pk.pem

关于google-app-engine - AppEngine 上的 SignedJwtAssertionCredentials 无法识别 PEM key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17993604/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com