diff options
author | Pat Ferate <pferate+github@gmail.com> | 2014-07-17 15:35:55 -0700 |
---|---|---|
committer | Pat Ferate <pferate+github@gmail.com> | 2014-07-17 15:35:55 -0700 |
commit | 466e3737d7b7d9e48cf983872221ebb90eddbdcf (patch) | |
tree | 206de08efc065bc9c42d7d996d16652cc3bbf887 /oauth2client/crypt.py | |
parent | ca96e1a4245812825c671ccc010b8245a831a2fa (diff) | |
download | oauth2client-466e3737d7b7d9e48cf983872221ebb90eddbdcf.tar.gz |
Trying to handle both OpenSSL 0.13 and 0.14.
Major change in load_pkcs12:
0.13: Need str
0.14: Need bytes
Diffstat (limited to 'oauth2client/crypt.py')
-rw-r--r-- | oauth2client/crypt.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/oauth2client/crypt.py b/oauth2client/crypt.py index 1082c40..4d92545 100644 --- a/oauth2client/crypt.py +++ b/oauth2client/crypt.py @@ -136,10 +136,17 @@ try: if parsed_pem_key: pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key) else: + # OpenSSL 0.13 needs password to be str + # OpenSSL 0.14 needs password to be bytes # Ensure password is str if isinstance(password, bytes): password = bytes.decode(password) - pkey = crypto.load_pkcs12(key, password).get_privatekey() + try: + pkey = crypto.load_pkcs12(key, password).get_privatekey() + except TypeError: + # Failed as str, so let's try with bytes (probably 0.14+) + password = str.encode(password) + pkey = crypto.load_pkcs12(key, password).get_privatekey() return OpenSSLSigner(pkey) except ImportError: |