Allow unicode as well as bytes in all the load APIs as well
diff --git a/OpenSSL/crypto.py b/OpenSSL/crypto.py
index 7dc31c8..918d33d 100644
--- a/OpenSSL/crypto.py
+++ b/OpenSSL/crypto.py
@@ -1202,6 +1202,9 @@
:return: The X509 object
"""
+ if isinstance(buffer, _text_type):
+ buffer = buffer.encode("ascii")
+
bio = _new_mem_buf(buffer)
if type == FILETYPE_PEM:
@@ -1988,6 +1991,9 @@
:return: The PKey object
"""
+ if isinstance(buffer, _text_type):
+ buffer = buffer.encode("ascii")
+
bio = _new_mem_buf(buffer)
helper = _PassphraseHelper(type, passphrase)
@@ -2044,6 +2050,9 @@
:param buffer: The buffer the certificate request is stored in
:return: The X509Req object
"""
+ if isinstance(buffer, _text_type):
+ buffer = buffer.encode("ascii")
+
bio = _new_mem_buf(buffer)
if type == FILETYPE_PEM:
@@ -2137,6 +2146,9 @@
:return: The PKey object
"""
+ if isinstance(buffer, _text_type):
+ buffer = buffer.encode("ascii")
+
bio = _new_mem_buf(buffer)
if type == FILETYPE_PEM:
@@ -2163,6 +2175,9 @@
:param buffer: The buffer with the pkcs7 data.
:return: The PKCS7 object
"""
+ if isinstance(buffer, _text_type):
+ buffer = buffer.encode("ascii")
+
bio = _new_mem_buf(buffer)
if type == FILETYPE_PEM:
@@ -2191,6 +2206,9 @@
:param passphrase: (Optional) The password to decrypt the PKCS12 lump
:returns: The PKCS12 object
"""
+ if isinstance(buffer, _text_type):
+ buffer = buffer.encode("ascii")
+
bio = _new_mem_buf(buffer)
p12 = _lib.d2i_PKCS12_bio(bio, _ffi.NULL)