INNER CODE UNIT · Python
_VerifyHelper
pyca/pyopenssl · src/OpenSSL/SSL.py:469
class _VerifyHelper:
"""
Wrap a callback such that it can be used as a certificate verification
callback.
"""
def __init__(self, callback: _VerifyCallback) -> None:
@wraps(callback)
def wrapper(ok, store_ctx): # type: ignore[no-untyped-def]
x509 = _lib.X509_STORE_CTX_get_current_cert(store_ctx)
_lib.X509_up_ref(x509)
cert = X509._from_raw_x509_ptr(x509)
error_number = _lib.X509_STORE_CTX_get_error(store_ctx)
error_depth = _lib.X509_STORE_CTX_get_error_depth(store_ctx)
index = _lib.SSL_get_ex_data_X509_STORE_CTX_idx()
ssl = _lib.X509_STORE_CTX_get_ex_data(store_ctx, index)
connection = Connection._reverse_mapping[ssl]