1313 lib as _lib ,
1414 exception_from_error_queue as _exception_from_error_queue ,
1515 byte_string as _byte_string ,
16- native as _native ,
1716 path_string as _path_string ,
1817 UNSPECIFIED as _UNSPECIFIED ,
1918 text_to_bytes_and_warn as _text_to_bytes_and_warn ,
@@ -672,7 +671,7 @@ def __repr__(self):
672671 _openssl_assert (format_result != _ffi .NULL )
673672
674673 return "<X509Name object '%s'>" % (
675- _native ( _ffi .string (result_buffer )),
674+ _ffi .string (result_buffer ). decode ( "utf-8" ),
676675 )
677676
678677 def hash (self ):
@@ -821,11 +820,11 @@ def _subjectAltNameString(self):
821820 except KeyError :
822821 bio = _new_mem_buf ()
823822 _lib .GENERAL_NAME_print (bio , name )
824- parts .append (_native ( _bio_to_string (bio )))
823+ parts .append (_bio_to_string (bio ). decode ( "utf-8" ))
825824 else :
826- value = _native (
827- _ffi . buffer ( name . d . ia5 . data , name . d . ia5 . length )[:]
828- )
825+ value = _ffi . buffer ( name . d . ia5 . data , name . d . ia5 . length )[
826+ :
827+ ]. decode ( "utf-8" )
829828 parts .append (label + ":" + value )
830829 return ", " .join (parts )
831830
@@ -840,7 +839,7 @@ def __str__(self):
840839 print_result = _lib .X509V3_EXT_print (bio , self ._extension , 0 , 0 )
841840 _openssl_assert (print_result != 0 )
842841
843- return _native ( _bio_to_string (bio ))
842+ return _bio_to_string (bio ). decode ( "utf-8" )
844843
845844 def get_critical (self ):
846845 """
@@ -1381,7 +1380,7 @@ def has_expired(self):
13811380 :return: ``True`` if the certificate has expired, ``False`` otherwise.
13821381 :rtype: bool
13831382 """
1384- time_string = _native ( self .get_notAfter ())
1383+ time_string = self .get_notAfter (). decode ( "utf-8" )
13851384 not_after = datetime .datetime .strptime (time_string , "%Y%m%d%H%M%SZ" )
13861385
13871386 return not_after < datetime .datetime .utcnow ()
@@ -1850,13 +1849,11 @@ def _exception_from_context(self):
18501849 errors = [
18511850 _lib .X509_STORE_CTX_get_error (self ._store_ctx ),
18521851 _lib .X509_STORE_CTX_get_error_depth (self ._store_ctx ),
1853- _native (
1854- _ffi .string (
1855- _lib .X509_verify_cert_error_string (
1856- _lib .X509_STORE_CTX_get_error (self ._store_ctx )
1857- )
1852+ _ffi .string (
1853+ _lib .X509_verify_cert_error_string (
1854+ _lib .X509_STORE_CTX_get_error (self ._store_ctx )
18581855 )
1859- ),
1856+ ). decode ( "utf-8" ) ,
18601857 ]
18611858 # A context error should always be associated with a certificate, so we
18621859 # expect this call to never return :class:`None`.
0 commit comments