cert_chain_resolver package
Submodules
cert_chain_resolver.resolver module
- cert_chain_resolver.resolver.resolve(bytes_cert: bytes, _chain: CertificateChain | None = None, root_ca_store: CAStore | None = None) CertificateChain[source]
A recursive function that follows the CA issuer chain
- Parameters:
bytes_cert – A DER/PKCS7/PEM certificate
_chain – Chain to complete. Defaults to None.
root_ca_store – A CAStore to use for completing the chain with a root certificate in case the intermediates do not provide a location
- Returns:
All resolved certificates in chain
cert_chain_resolver.models module
- class cert_chain_resolver.models.Cert(x509_obj: Certificate)[source]
Bases:
objectThe
Certobject, which is a convenience wrapper for interacting with the underlyingcryptography.x509.Certificateobject- Parameters:
x509_obj – An instance of
cryptography.x509.Certificate- Raises:
TypeError – given type is not an instance of
cryptography.x509.Certificate
- property common_name: str
Extracted common name from the underlying
cryptography.x509.Certificateobject
- export(encoding: ~cryptography.hazmat.primitives._serialization.Encoding = <Encoding.PEM: 'PEM'>) str[source]
Export the
cryptography.x509.Certificateobject” as text- Parameters:
encoding (
cryptography.hazmat.primitives.serialization.Encoding, optional) – The output format. Defaults to Encoding.PEM.- Returns:
ascii formatted
- property fingerprint: str
ascii encoded sha256 fingerprint by calling
get_fingerprint()
- get_fingerprint(_hash: ~typing.Type[~cryptography.hazmat.primitives.hashes.HashAlgorithm] = <class 'cryptography.hazmat.primitives.hashes.SHA256'>) str[source]
Get fingerprint of the certificate
- Parameters:
_hash (
cryptography.hazmat.primitives.hashes, optional) – Hasher to use. Defaults to hashes.SHA256.- Returns:
hex representation of the fingerprint
- property issuer: str
RFC4515 formatted string of the issuer field from the underlying
cryptography.x509.Certificateobject
- classmethod load(bytes_input: bytes) Cert[source]
Create a
Certobject:param bytes_input
bytesPEM or DER:- Raises:
ImproperlyFormattedCert <ImproperlyFormattedCert> –
- property not_valid_after: datetime.datetime
Date from the underlying
cryptography.x509.Certificateobject
- property not_valid_before: datetime.datetime
Date from the underlying
cryptography.x509.Certificateobject
- property serial: int
gets the serial from the underlying
cryptography.x509.Certificateobject
- property signature_hash_algorithm: str
gets the signature hashing algorithm name from the underlying
cryptography.x509.Certificateobject
- property subject: str
RFC4515 formatted string of the subject field from the underlying
cryptography.x509.Certificateobject
- class cert_chain_resolver.models.CertificateChain(chain: CertificateChain | None | List[Cert] = None)[source]
Bases:
objectCreates an iterable that contains a list of
Certobjects.- Parameters:
chain – Create a new CertificateChain based on this chain. Defaults to None.
- property intermediates: CertificateChain
A new
CertificateChainobject with only intermediate certificates
- classmethod load_from_pem(input_bytes: bytes) CertificateChain[source]
Create a
CertificateChainobject from a PEM formatted file
cert_chain_resolver.utils module
- cert_chain_resolver.utils.load_ascii_to_x509(bytes_input: bytes) Certificate[source]
Converts ASCII PKCS7 or Certificate to a
cryptography.x509.Certificateobject
- cert_chain_resolver.utils.load_bytes_to_x509(bytes_input: bytes) Certificate[source]
Converts Certificate / PKCS7 in ASCII or DER to
cryptography.x509.Certificateobject
- cert_chain_resolver.utils.load_der_to_x509(bytes_input: bytes) Certificate[source]
Converts bytes formatted DER (PKCS7 or Cert) to
cryptography.x509.Certificateobject