Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Unified Diff: client/third_party/oauth2client/_openssl_crypt.py

Issue 1768993002: Update oauth2client to v2.0.1 and googleapiclient to v1.5.0. Base URL: git@github.com:luci/luci-py.git@master
Patch Set: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/third_party/oauth2client/_openssl_crypt.py
diff --git a/client/third_party/oauth2client/_openssl_crypt.py b/client/third_party/oauth2client/_openssl_crypt.py
index d024cf30aa5ac872af24e3e7ee3e33118c80a810..7a76fb7157f156a354b554f90b859d5ed8cba672 100644
--- a/client/third_party/oauth2client/_openssl_crypt.py
+++ b/client/third_party/oauth2client/_openssl_crypt.py
@@ -68,6 +68,7 @@ class OpenSSLVerifier(object):
Raises:
OpenSSL.crypto.Error: if the key_pem can't be parsed.
"""
+ key_pem = _to_bytes(key_pem)
if is_x509_cert:
pubkey = crypto.load_certificate(crypto.FILETYPE_PEM, key_pem)
else:
@@ -112,6 +113,7 @@ class OpenSSLSigner(object):
Raises:
OpenSSL.crypto.Error if the key can't be parsed.
"""
+ key = _to_bytes(key)
parsed_pem_key = _parse_pem_key(key)
if parsed_pem_key:
pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key)
@@ -121,19 +123,17 @@ class OpenSSLSigner(object):
return OpenSSLSigner(pkey)
-def pkcs12_key_as_pem(private_key_text, private_key_password):
- """Convert the contents of a PKCS12 key to PEM using OpenSSL.
+def pkcs12_key_as_pem(private_key_bytes, private_key_password):
+ """Convert the contents of a PKCS#12 key to PEM using pyOpenSSL.
Args:
- private_key_text: String. Private key.
- private_key_password: String. Password for PKCS12.
+ private_key_bytes: Bytes. PKCS#12 key in DER format.
+ private_key_password: String. Password for PKCS#12 key.
Returns:
- String. PEM contents of ``private_key_text``.
+ String. PEM contents of ``private_key_bytes``.
"""
- decoded_body = base64.b64decode(private_key_text)
private_key_password = _to_bytes(private_key_password)
-
- pkcs12 = crypto.load_pkcs12(decoded_body, private_key_password)
+ pkcs12 = crypto.load_pkcs12(private_key_bytes, private_key_password)
return crypto.dump_privatekey(crypto.FILETYPE_PEM,
pkcs12.get_privatekey())

Powered by Google App Engine
This is Rietveld 408576698