Skip to content

Commit

Permalink
Use openssl_assert for error handling in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
alex authored Aug 5, 2024
1 parent 3ada747 commit 1769c4a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/OpenSSL/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,8 +1665,7 @@ def add_extensions(
raise ValueError("One of the elements is not an X509Extension")

add_result = _lib.X509_add_ext(self._x509, ext._extension, -1)
if not add_result:
_raise_current_error()
_openssl_assert(add_result == 1)

def get_extension(self, index: int) -> _X509ExtensionInternal:
"""
Expand Down Expand Up @@ -1777,9 +1776,7 @@ def add_crl(

bio = _new_mem_buf(crl.public_bytes(Encoding.DER))
openssl_crl = _lib.d2i_X509_CRL_bio(bio, _ffi.NULL)
if openssl_crl == _ffi.NULL:
_raise_current_error()

_openssl_assert(openssl_crl != _ffi.NULL)
crl = _ffi.gc(openssl_crl, _lib.X509_CRL_free)
elif isinstance(crl, _CRLInternal):
crl = crl._crl
Expand Down

0 comments on commit 1769c4a

Please sign in to comment.