dissect.target.helpers.certificate

Module Contents

Functions

compute_pem_fingerprints

Compute the MD5, SHA-1 and SHA-256 fingerprint hash of a x509 certificate PEM.

format_serial_number_as_hex

Format serial_number from integer to hex.

parse_x509

Parses a PEM file. Returns a CertificateREcord. Does not parse a public key embedded in a x509 certificate.

Attributes

dissect.target.helpers.certificate.HAS_ASN1 = True
dissect.target.helpers.certificate.COMMON_CERTIFICATE_FIELDS = [('digest', 'fingerprint'), ('varint', 'serial_number'), ('string', 'serial_number_hex'),...
dissect.target.helpers.certificate.CertificateRecord
dissect.target.helpers.certificate.NAMEOID_TO_NAME
dissect.target.helpers.certificate.compute_pem_fingerprints(pem: str | bytes) tuple[str, str, str]

Compute the MD5, SHA-1 and SHA-256 fingerprint hash of a x509 certificate PEM.

dissect.target.helpers.certificate.format_serial_number_as_hex(serial_number: int | None) str | None

Format serial_number from integer to hex.

Add a prefix 0 if output length is not pair, in order to be consistent with usual serial_number representation (navigator, openssl etc…). For negative number use the same representation as navigator, which differ from OpenSSL.

For example for -1337:

OpenSSL : Serial Number: -1337 (-0x539)
Navigator : FA C7
Parameters:

serial_number – The serial number to format as hex.

dissect.target.helpers.certificate.parse_x509(file: str | bytes | pathlib.Path) CertificateRecord

Parses a PEM file. Returns a CertificateREcord. Does not parse a public key embedded in a x509 certificate.