summaryrefslogtreecommitdiff
path: root/src/OpenSSL/crypto.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2021-12-19 16:00:32 -0500
committerGitHub <noreply@github.com>2021-12-20 05:00:32 +0800
commitde073c62c809b2cd67315c5b3ae99ef38fcd26a9 (patch)
tree480a3c4a067f4b8401b39cc1fe4d543a20d7eb33 /src/OpenSSL/crypto.py
parentc175f152a4b4c02f166035c915a847c3281b1e8c (diff)
downloadpyopenssl-git-de073c62c809b2cd67315c5b3ae99ef38fcd26a9.tar.gz
Remove native, it's behavior is confusing (#1069)
Instead just decode stuff at the call-sites -- 100% of which were passing bytes
Diffstat (limited to 'src/OpenSSL/crypto.py')
-rw-r--r--src/OpenSSL/crypto.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index e395ee3..4c5d9f3 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -13,7 +13,6 @@ from OpenSSL._util import (
lib as _lib,
exception_from_error_queue as _exception_from_error_queue,
byte_string as _byte_string,
- native as _native,
path_string as _path_string,
UNSPECIFIED as _UNSPECIFIED,
text_to_bytes_and_warn as _text_to_bytes_and_warn,
@@ -672,7 +671,7 @@ class X509Name(object):
_openssl_assert(format_result != _ffi.NULL)
return "<X509Name object '%s'>" % (
- _native(_ffi.string(result_buffer)),
+ _ffi.string(result_buffer).decode("utf-8"),
)
def hash(self):
@@ -821,11 +820,11 @@ class X509Extension(object):
except KeyError:
bio = _new_mem_buf()
_lib.GENERAL_NAME_print(bio, name)
- parts.append(_native(_bio_to_string(bio)))
+ parts.append(_bio_to_string(bio).decode("utf-8"))
else:
- value = _native(
- _ffi.buffer(name.d.ia5.data, name.d.ia5.length)[:]
- )
+ value = _ffi.buffer(name.d.ia5.data, name.d.ia5.length)[
+ :
+ ].decode("utf-8")
parts.append(label + ":" + value)
return ", ".join(parts)
@@ -840,7 +839,7 @@ class X509Extension(object):
print_result = _lib.X509V3_EXT_print(bio, self._extension, 0, 0)
_openssl_assert(print_result != 0)
- return _native(_bio_to_string(bio))
+ return _bio_to_string(bio).decode("utf-8")
def get_critical(self):
"""
@@ -1381,7 +1380,7 @@ class X509(object):
:return: ``True`` if the certificate has expired, ``False`` otherwise.
:rtype: bool
"""
- time_string = _native(self.get_notAfter())
+ time_string = self.get_notAfter().decode("utf-8")
not_after = datetime.datetime.strptime(time_string, "%Y%m%d%H%M%SZ")
return not_after < datetime.datetime.utcnow()
@@ -1850,13 +1849,11 @@ class X509StoreContext(object):
errors = [
_lib.X509_STORE_CTX_get_error(self._store_ctx),
_lib.X509_STORE_CTX_get_error_depth(self._store_ctx),
- _native(
- _ffi.string(
- _lib.X509_verify_cert_error_string(
- _lib.X509_STORE_CTX_get_error(self._store_ctx)
- )
+ _ffi.string(
+ _lib.X509_verify_cert_error_string(
+ _lib.X509_STORE_CTX_get_error(self._store_ctx)
)
- ),
+ ).decode("utf-8"),
]
# A context error should always be associated with a certificate, so we
# expect this call to never return :class:`None`.