Skip to content

Commit 5e766ec

Browse files
authored
Use openssl_assert for error handling in more places (#1346)
1 parent 3b5244f commit 5e766ec

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/OpenSSL/crypto.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,8 +1665,7 @@ def add_extensions(
16651665
raise ValueError("One of the elements is not an X509Extension")
16661666

16671667
add_result = _lib.X509_add_ext(self._x509, ext._extension, -1)
1668-
if not add_result:
1669-
_raise_current_error()
1668+
_openssl_assert(add_result == 1)
16701669

16711670
def get_extension(self, index: int) -> _X509ExtensionInternal:
16721671
"""
@@ -1777,9 +1776,7 @@ def add_crl(
17771776

17781777
bio = _new_mem_buf(crl.public_bytes(Encoding.DER))
17791778
openssl_crl = _lib.d2i_X509_CRL_bio(bio, _ffi.NULL)
1780-
if openssl_crl == _ffi.NULL:
1781-
_raise_current_error()
1782-
1779+
_openssl_assert(openssl_crl != _ffi.NULL)
17831780
crl = _ffi.gc(openssl_crl, _lib.X509_CRL_free)
17841781
elif isinstance(crl, _CRLInternal):
17851782
crl = crl._crl

0 commit comments

Comments
 (0)