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 StackOverflow 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
I had downloaded the required supporting libraries (httplib2, oauth2client) from https://developers.google.com/api-client-library/python/start/installation#appengine--
You received this message because you are subscribed to the Google Groups "Google Identity Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-identity-t...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
openssl pkcs12 -in myapp-1234.p12 -nocerts -passin pass:notasecret -nodes -out key.pem Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1049, in add_context_wrapper
return synctaskletfunc(*args, **kwds)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1030, in synctasklet_wrapper
return taskletfunc(*args, **kwds).get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1003, in tasklet_wrapper
result = func(*args, **kwds)
File "/base/data/home/apps/s~myapp/1.378327257984780792/main_v3.py", line 1350, in get
gitkit_user = gitkit_instance.VerifyGitkitToken (self.request.cookies['gtoken'])
File "/base/data/home/apps/s~myapp/1.378327257984780792/gitkitclient.py", line 216, in VerifyGitkitToken
certs = self.rpc_helper.GetPublicCert()
File "/base/data/home/apps/s~myapp/1.378327257984780792/rpchelper.py", line 157, in GetPublicCert
headers = {'Authorization': 'Bearer ' + self._GetAccessToken()}
File "/base/data/home/apps/s~myapp/1.378327257984780792/rpchelper.py", line 196, in _GetAccessToken
'assertion': self._GenerateAssertion(),
File "/base/data/home/apps/s~myapp/1.378327257984780792/rpchelper.py", line 219, in _GenerateAssertion
crypt.Signer.from_string(self.service_account_key),
File "/base/data/home/apps/s~myapp/1.378327257984780792/oauth2client/crypt.py", line 237, in from_string
'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 nativelibraries:
- name: pycrypto
version: latest
- Mengcheng
To unsubscribe from this group and stop receiving emails from it, send an email to google-identity-toolkit+unsub...@googlegroups.com.
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_are_present_here_which_i_have_replaced_for_this_post=
-----END PRIVATE KEY-----
localKeyID:". To unsubscribe from this group and stop receiving emails from it, send an email to google-identity-t...@googlegroups.com.
-----BEGIN PRIVATE KEY-----
lots_of_characters_are_present_here_which_i_have_replaced_for_this_post=
-----END PRIVATE KEY-----Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1049, in add_context_wrapper
return synctaskletfunc(*args, **kwds)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1030, in synctasklet_wrapper
return taskletfunc(*args, **kwds).get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1003, in tasklet_wrapper
result = func(*args, **kwds)
File "/base/data/home/apps/s~myapp/1.378327768548187440/main_v3.py", line 1350, in get
gitkit_user = gitkit_instance.VerifyGitkitToken (self.request.cookies['gtoken'])
File "/base/data/home/apps/s~myapp/1.378327768548187440/gitkitclient.py", line 219, in VerifyGitkitToken
parsed = crypt.verify_signed_jwt_with_certs(jwt, certs, self.client_id)
File "/base/data/home/apps/s~myapp/1.378327768548187440/oauth2client/crypt.py", line 338, in verify_signed_jwt_with_certs
verifier = Verifier.from_string(pem, True)
File "/base/data/home/apps/s~myapp/1.378327768548187440/oauth2client/crypt.py", line 190, in from_string
'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.
- Mengcheng
To unsubscribe from this group and stop receiving emails from it, send an email to google-identity-toolkit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Google Identity Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-identity-t...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to google-identity-toolkit+unsub...@googlegroups.com.
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1049, in add_context_wrapper
return synctaskletfunc(*args, **kwds)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1030, in synctasklet_wrapper
return taskletfunc(*args, **kwds).get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1003, in tasklet_wrapper
result = func(*args, **kwds)
File "/base/data/home/apps/s~myapp/1.378382704328166956/main_v3.py", line 1350, in get
gitkit_user = gitkit_instance.VerifyGitkitToken (self.request.cookies['gtoken'])
File "/base/data/home/apps/s~myapp/1.378382704328166956/gitkitclient.py", line 219, in VerifyGitkitToken
parsed = crypt.verify_signed_jwt_with_certs(jwt, certs, self.client_id)
File "/base/data/home/apps/s~myapp/1.378382704328166956/oauth2client/crypt.py", line 363, in verify_signed_jwt_with_certs
verifier = Verifier.from_string(pem, True)
File "/base/data/home/apps/s~myapp/1.378382704328166956/oauth2client/crypt.py", line 209, in from_string
tbsCertificate.decode(cert[0])
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/pycrypto-2.6/Crypto/Util/asn1.py", line 244, in decode
idx += newInteger.decode(self.payload[idx:])
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/pycrypto-2.6/Crypto/Util/asn1.py", line 147, in decode
raise ValueError ("Negative INTEGER.")
ValueError: Negative INTEGER.
openssl pkcs12 -clcerts -nokeys -in myapp-36.p12 -out usercert.pem
Bag Attributes
friendlyName: privatekey
localKeyID: 66 77 88 99 22 33 44 55 66 77 88 99 20 35 56 65 88 68
subject=/CN=some_character_sequence_here_1.apps.googleusercontent.com
issuer=/CN=some_character_sequence_here_1.apps.googleusercontent.com
-----BEGIN CERTIFICATE-----
some_character_sequence_here_2
-----END CERTIFICATE-----Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1049, in add_context_wrapper
return synctaskletfunc(*args, **kwds)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1030, in synctasklet_wrapper
return taskletfunc(*args, **kwds).get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1003, in tasklet_wrapper
result = func(*args, **kwds)
File "/base/data/home/apps/s~myapp/1.378405227381861331/main_v3.py", line 1350, in get
gitkit_user = gitkit_instance.VerifyGitkitToken (self.request.cookies['gtoken'])
File "/base/data/home/apps/s~myapp/1.378405227381861331/gitkitclient.py", line 216, in VerifyGitkitToken
certs = self.rpc_helper.GetPublicCert()
File "/base/data/home/apps/s~myapp/1.378405227381861331/rpchelper.py", line 157, in GetPublicCert
headers = {'Authorization': 'Bearer ' + self._GetAccessToken()}
File "/base/data/home/apps/s~myapp/1.378405227381861331/rpchelper.py", line 196, in _GetAccessToken
'assertion': self._GenerateAssertion(),
File "/base/data/home/apps/s~myapp/1.378405227381861331/rpchelper.py", line 219, in _GenerateAssertion
crypt.Signer.from_string(self.service_account_key),
File "/base/data/home/apps/s~myapp/1.378405227381861331/oauth2client/crypt.py", line 262, in from_string
'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
-----BEGIN CERTIFICATE-----
some_character_sequence_here_2
-----END CERTIFICATE----- Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1049, in add_context_wrapper
return synctaskletfunc(*args, **kwds)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1030, in synctasklet_wrapper
return taskletfunc(*args, **kwds).get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 1003, in tasklet_wrapper
result = func(*args, **kwds)
File "/base/data/home/apps/s~myapp/1.378404742263836203/main_v3.py", line 1350, in get
gitkit_user = gitkit_instance.VerifyGitkitToken (self.request.cookies['gtoken'])
File "/base/data/home/apps/s~myapp/1.378404742263836203/gitkitclient.py", line 216, in VerifyGitkitToken
certs = self.rpc_helper.GetPublicCert()
File "/base/data/home/apps/s~myapp/1.378404742263836203/rpchelper.py", line 157, in GetPublicCert
headers = {'Authorization': 'Bearer ' + self._GetAccessToken()}
File "/base/data/home/apps/s~myapp/1.378404742263836203/rpchelper.py", line 196, in _GetAccessToken
'assertion': self._GenerateAssertion(),
File "/base/data/home/apps/s~myapp/1.378404742263836203/rpchelper.py", line 219, in _GenerateAssertion
crypt.Signer.from_string(self.service_account_key),
File "/base/data/home/apps/s~myapp/1.378404742263836203/oauth2client/crypt.py", line 259, in from_string
pkey = RSA.importKey(key)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/pycrypto-2.6/Crypto/PublicKey/RSA.py", line 665, in importKey
return self._importKeyDER(der)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/pycrypto-2.6/Crypto/PublicKey/RSA.py", line 588, in _importKeyDER
raise ValueError("RSA key format is not supported")
ValueError: RSA key format is not supported