pki.models.certificateΒΆ
Module that contains the CertificateModel.
ClassesΒΆ
X509 Certificate Model. |
|
Model to store revoked certificates. |
Module ContentsΒΆ
- class pki.models.certificate.CertificateModel(*args, **kwargs)[source]ΒΆ
Bases:
trustpoint.logger.LoggerMixin,util.db.CustomDeleteActionModelX509 Certificate Model.
See RFC5280 for more information.
- class CertificateStatus(*args, **kwds)[source]ΒΆ
Bases:
django.db.models.TextChoicesCertificateModel status.
- class Version(*args, **kwds)[source]ΒΆ
Bases:
django.db.models.IntegerChoicesX509 RFC 5280 - Certificate Version.
- class SignatureAlgorithmOidChoices(*args, **kwds)[source]ΒΆ
Bases:
django.db.models.TextChoicesSignature Algorithm OIDs.
- class PublicKeyAlgorithmOidChoices(*args, **kwds)[source]ΒΆ
Bases:
django.db.models.TextChoicesPublic Key Algorithm OIDs.
- class PublicKeyEcCurveOidChoices(*args, **kwds)[source]ΒΆ
Bases:
django.db.models.TextChoicesPublic Key EC Curve OIDs.
- __str__()[source]ΒΆ
Human-readable representation of the CertificateModel instance.
- Return type:
str
- save(*_args, **_kwargs)[source]ΒΆ
Save method must not be called directly to protect the integrity.
This method makes sure save() is not called by mistake.
- Raises:
NotImplementedError β
- Parameters:
_args (Any)
_kwargs (Any)
- Return type:
None
- property signature_algorithm_padding_scheme: str[source]ΒΆ
Padding scheme if RSA is used, otherwise None.
- Return type:
str
- property signature_suite: trustpoint_core.oid.SignatureSuite[source]ΒΆ
Signature Suite of the certificate.
- Return type:
trustpoint_core.oid.SignatureSuite
- property public_key_info: trustpoint_core.oid.PublicKeyInfo[source]ΒΆ
Public Key Info of the certificate.
- Return type:
trustpoint_core.oid.PublicKeyInfo
- property certificate_status: CertificateStatus[source]ΒΆ
Status of the certificate.
- Return type:
- property days_left: int[source]ΒΆ
Returns number of days from now until not_valid_after. If expired, returns 0.
- Return type:
int
- property is_root_ca: bool[source]ΒΆ
Check if the certificate is a root CA certificate.
- Return type:
bool
- property is_end_entity: bool[source]ΒΆ
Check if the certificate is an end entity certificate.
- Return type:
bool
- classmethod get_cert_by_sha256_fingerprint(sha256_fingerprint)[source]ΒΆ
Get a CertificateModel instance by its SHA256 fingerprint.
- Parameters:
sha256_fingerprint (str)
- Return type:
None | CertificateModel
- static _get_subject(cert)[source]ΒΆ
- Parameters:
cert (cryptography.x509.Certificate)
- Return type:
list[tuple[str, str]]
- static _get_issuer_name(cert)[source]ΒΆ
- Parameters:
cert (cryptography.x509.Certificate)
- Return type:
list[tuple[str, str]]
- static _get_spki_info(cert)[source]ΒΆ
- Parameters:
cert (cryptography.x509.Certificate)
- Return type:
tuple[trustpoint_core.oid.PublicKeyAlgorithmOid, int, trustpoint_core.oid.NamedCurve]
- get_certificate_serializer()[source]ΒΆ
Get the serializer for the certificate.
- Return type:
trustpoint_core.serializer.CertificateSerializer
- get_public_key_serializer()[source]ΒΆ
Get the serializer for the certificateβs public key.
- Return type:
trustpoint_core.serializer.PublicKeySerializer
- get_certificate_chain()[source]ΒΆ
Get the certificate chain from this certificate up to the root CA.
- Return type:
list[CertificateModel]
- classmethod _save_certificate(certificate)[source]ΒΆ
- Parameters:
certificate (cryptography.x509.Certificate | trustpoint_core.serializer.CertificateSerializer)
- Return type:
- static _save_attribute_and_value_pairs(oid, value)[source]ΒΆ
- Parameters:
oid (str)
value (str)
- Return type:
- classmethod _save_subject(cert_model, subject)[source]ΒΆ
- Parameters:
cert_model (CertificateModel)
subject (list[tuple[str, str]])
- Return type:
None
- classmethod _save_issuer(cert_model, issuer)[source]ΒΆ
- Parameters:
cert_model (CertificateModel)
issuer (list[tuple[str, str]])
- Return type:
None
- static _save_extensions(cert_model, cert)[source]ΒΆ
- Parameters:
cert_model (CertificateModel)
cert (cryptography.x509.Certificate)
- Return type:
None
- classmethod _atomic_save(cert_model, certificate, subject, issuer)[source]ΒΆ
- Parameters:
cert_model (CertificateModel)
certificate (cryptography.x509.Certificate)
subject (list[tuple[str, str]])
issuer (list[tuple[str, str]])
- Return type:
- classmethod save_certificate(certificate)[source]ΒΆ
Store the certificate in the database.
- Returns:
The certificate object that has just been saved.
- Return type:
trustpoint.pki.models.Certificate
- Parameters:
certificate (cryptography.x509.Certificate | trustpoint_core.serializer.CertificateSerializer)