Certificate Verification
aia_chaser.verify
¶
VerifyCertificatesConfig
dataclass
¶
Configuration to verify certificates.
| ATTRIBUTE | DESCRIPTION |
|---|---|
fingerprint_hash_alg |
Hash algorithm used to verify that the
root certificate from the chain is the same as the one
found in the trusted certificates. Defaults to
TYPE:
|
crl_enabled |
Whether or not perform CRL validation.
TYPE:
|
ocsp_enabled |
Whether or not perform OCSP validation. Defaults to True.
TYPE:
|
ocsp_hash_alg |
Hash algorithm used to construct OCSP requests.
Defaults to
TYPE:
|
ocsp_ignore_unknown |
Whether to ignore OCSP’s status UNKNOWN or consider it a verification error. Defaults to True.
TYPE:
|
ocsp_verify_responder |
Whether to verify responder certificate. See
TYPE:
|
verification_time |
Timestamp used to verify certificate validity
period. Defaults to
TYPE:
|
retry_config |
Configuration for HTTP retry behavior when downloading CRLs or making OCSP requests. Defaults to 3 attempts with exponential backoff.
TYPE:
|
VerifyOcspConfig
dataclass
¶
Configuration to verify certificates.
| ATTRIBUTE | DESCRIPTION |
|---|---|
hash_alg |
Hash algorithm used to construct OCSP requests.
Defaults to
TYPE:
|
nonce_size |
Size in bytes of the OCSP nonce.
TYPE:
|
ignore_unknown |
Whether to ignore OCSP’s status UNKNOWN or consider it a verification error. Defaults to True.
TYPE:
|
verify_responder |
Whether to verify responder certificate. If enabled there are 3 possibilities:
TYPE:
|
trusted |
Trusted certificates mapping from subject (name) to certificate. If not provided a responder certificate verification may fail.
TYPE:
|
retry_config |
Configuration for HTTP retry behavior when making OCSP requests. Defaults to 3 attempts with exponential backoff.
TYPE:
|
verify_certificate_chain(certificates, trusted=None, config=None)
¶
Verifies the integrity of the certificates chain.
The verification checks that each certificate in the sequence is signed by the next one and that all are valid certificates.
| PARAMETER | DESCRIPTION |
|---|---|
certificates
|
Chain of certificates starting with the leaf and ending in the root CA certificate.
TYPE:
|
trusted
|
Trusted certificates mapping from subject, formatted as rfc4514, to certificate. If not provided root certificate verification will be skipped.
TYPE:
|
config
|
Configuration of the verification process.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
CertificateChainError
|
If a verification error is detected on
any of the certificates from the chain. It will also
be raised if trusted is given |
verify_certificate_validity_period(certificate, verification_time=None)
¶
Verifies certificate validity period (not valid before/after).
| PARAMETER | DESCRIPTION |
|---|---|
certificate
|
Certificate to verify.
TYPE:
|
verification_time
|
datetime value to use as reference when verifying the validity period. If not given uses UTC time.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
CertificateExpiredError
|
If the certificate is outside its validity period. |
CertificateTimeZoneError
|
If |
verify_crl_status(certificate, verification_time, retry_config=None)
¶
Verifies the status of a certificate using revocation lists.
| PARAMETER | DESCRIPTION |
|---|---|
certificate
|
The certificate whose revocation status needs to be verified.
TYPE:
|
verification_time
|
time at which the verification is being conducted.
Defaults to
TYPE:
|
retry_config
|
Configuration for HTTP retry behavior.
TYPE:
|
verify_directly_issued_by(certificate, issuer)
¶
Verifies that a certificate was issued by the provided issuer.
This function delegates to x509.Certificate.verify_directly_issued_by
to check if the given certificate’s issuer matches the provided issuer
certificate and to validate the issuer’s signature. If the check fails,
specific exceptions are raised to indicate the type of failure.
| PARAMETER | DESCRIPTION |
|---|---|
certificate
|
The certificate to validate.
TYPE:
|
issuer
|
The certificate of the issuer expected to have issued the given certificate.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
CertificateIssuerNameError
|
If the issuer’s subject name does not match the certificate’s issuer name. |
CertificateSignatureError
|
If the issuer’s signature on the certificate is invalid. |
verify_ocsp_status(certificate, issuer, config=None)
¶
Verifies the status of a certificate using Online Certificate Status Protocol.
| PARAMETER | DESCRIPTION |
|---|---|
certificate
|
The certificate whose revocation status needs to be verified.
TYPE:
|
issuer
|
The issuer certificate that signed the target certificate.
TYPE:
|
config
|
Configuration of the OCSP verification process.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
OcspRevokedStatusError
|
The certificate status is |
OcspUnknownStatusError
|
The certificate status is |
OcspHttpError
|
An HTTP error happened while requesting the OCSP status. |
OcspResponseStatusError
|
The OCSP response status is not |
OcspResponseUnsignedError
|
The OCSP response is not signed. |
OcspResponseSignatureError
|
The OCSP response is not signed by the responder certificate. |
CertificateKeyTypeError
|
The responder certificate key is not supported. |
| WARNS | DESCRIPTION |
|---|---|
UserWarning
|
A warning is issued if a hash algorithm other than SHA-1 is
used, as some OCSP servers may not support other hash algorithms
and may fail with |
verify_root_certificate(root_cert, trusted, verification_time=None, hash_alg=None)
¶
Verifies the validity of the provided root certificate.
| PARAMETER | DESCRIPTION |
|---|---|
root_cert
|
Certificate to verify.
TYPE:
|
verification_time
|
datetime value to validate the certificates
validity period.
Defaults to
TYPE:
|
trusted
|
Trusted certificates mapping from subject (name) to certificate.
TYPE:
|
hash_alg
|
Hashing algorithm used for operations like fingerprint comparison, etc. Defaults to SHA-256.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RootCertificateNotFoundError
|
If the root certificate cannot
be found in |
CertificateFingerprintError
|
If the root certificate fingerprint does not match the trusted certificate fingerprint. |