aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/backends/openssl/backend.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2018-12-02 19:20:33 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2018-12-02 06:20:33 -0500
commitafaa4c65b58e31f36a8162f88ad79829f68d0a86 (patch)
tree0660c30fe1382a2507c017b0df20c51544462258 /src/cryptography/hazmat/backends/openssl/backend.py
parent3531439f8a09dd40102ac0e336cb962e86d8bf57 (diff)
downloadcryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.tar.gz
cryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.tar.bz2
cryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.zip
centralize our bytes check (#4622)
this will make life a bit easier when we support bytearrays
Diffstat (limited to 'src/cryptography/hazmat/backends/openssl/backend.py')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index 5a22a555..ae966cd0 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -1203,8 +1203,8 @@ class Backend(object):
def _load_key(self, openssl_read_func, convert_func, data, password):
mem_bio = self._bytes_to_bio(data)
- if password is not None and not isinstance(password, bytes):
- raise TypeError("Password must be bytes")
+ if password is not None:
+ utils._check_bytes("password", password)
userdata = self._ffi.new("CRYPTOGRAPHY_PASSWORD_DATA *")
if password is not None:
@@ -2132,8 +2132,8 @@ class Backend(object):
def load_key_and_certificates_from_pkcs12(self, data, password):
if password is None:
password = self._ffi.NULL
- elif not isinstance(password, bytes):
- raise TypeError("Password must be a byte string or None")
+ else:
+ utils._check_bytes("password", password)
bio = self._bytes_to_bio(data)
p12 = self._lib.d2i_PKCS12_bio(bio.bio, self._ffi.NULL)