appengine 上的 SignedJwtAssertionCredentials(使用 pycrypto 2.6)不支持 PKCS12 格式,因此我正在尝试使用 PEM 密钥,正如各处所建议的那样。
这是我的代码:
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 密钥,使用以下命令进行转换:
openssl pkcs12 -in privatekey.p12 -nodes -nocerts > privatekey.pem
但我仍然收到此错误,好像它没有识别出这是 PEM 密钥:
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.
如果我只将文件名传递给构造函数(不读取文件内容),则会出现同样的错误
任何想法?