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.
NotImplementedError: PKCS12 format is not supported by the PyCrpto library..
– Inearthopenssl pkcs12 -clcerts -nokeys -in mycert.p12 -out usercert.pem
? Can you post the cert somewhere? – Skepticopenssl pkcs12 -in <key.p12> -nocerts -passin pass:notasecret -nodes -out <key.pem>
key.pem:Bag Attributes friendlyName: privatekey localKeyID: 54 69 6D 65 20 31 34 30 31 32 33 34 35 36 37 38 39 30 Key Attributes: <No Attributes> -----BEGIN PRIVATE KEY----- lots_of_characters_present_here_replaced_for_this_post= -----END PRIVATE KEY-----
Next, I deleted first 4 lines of .pem file. Final .pem looks like:-----BEGIN PRIVATE KEY----- lots_of_characters_are_present_here_which_i_have_replaced_for_this_post= -----END PRIVATE KEY-----
– Inearthopenssl pkcs12 -clcerts -nokeys -in myapp-36.p12 -out usercert.pem
. The generated certificate could be seen here (replaced sensitive data). I tried and got this error. Then I removed everything before "-----BEGIN PRIVATE KEY-----" and tried again. The new certificate is here. This time, I got this error. – Inearth