Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Warn user if .p12 support is not available because of missing crypto libraries #417

Closed
ddoskind opened this issue Feb 19, 2016 · 1 comment

Comments

@ddoskind
Copy link

If you try to create ServiceAccountCredentials without having PyOpenSSL installed, a UnicodeDecodeError is raised:

>>> from oauth2client import service_account
>>> service_account.ServiceAccountCredentials.from_p12_keyfile(CLIENT_ID, PATH_TO_P12_KEY_FILE)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "lib/python2.7/site-packages/oauth2client/service_account.py", line 245, in from_p12_keyfile
    private_key_password)
  File "lib/python2.7/site-packages/oauth2client/_pure_python_crypt.py", line 167, in from_string
    key = _from_bytes(key)  # pem expects str in Py3
  File "lib/python2.7/site-packages/oauth2client/_helpers.py", line 87, in _from_bytes
    if isinstance(value, six.binary_type) else value)
  File "lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x82 in position 1: invalid start byte

It would be better to use the existing (but unused, from what I can tell) _PKCS12_ERROR string inside service_account.py to let the user know what's going on.

@dhermes
Copy link
Contributor

dhermes commented Feb 20, 2016

Thanks for filing! I thought I caught this before it got parsed, though it seems I didn't check all three crypto implementations.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants