pki.models.crl ============== .. py:module:: pki.models.crl .. autoapi-nested-parse:: Module that contains the CrlModel. Module Contents --------------- .. py:class:: CrlModel(*args, **kwargs) Bases: :py:obj:`trustpoint.logger.LoggerMixin`, :py:obj:`util.db.CustomDeleteActionModel` Certificate Revocation List Model. This model stores CRLs for CAs (both issuing and non-issuing). Multiple CRLs can exist for a single CA to track CRL history. .. py:attribute:: ca .. py:attribute:: crl_pem .. py:attribute:: crl_number .. py:attribute:: this_update .. py:attribute:: next_update .. py:attribute:: is_active .. py:attribute:: created_at .. py:attribute:: updated_at .. py:class:: Meta Meta options for CrlModel. .. py:attribute:: verbose_name .. py:attribute:: verbose_name_plural .. py:attribute:: ordering :type: ClassVar[list[str]] :value: ['-this_update'] .. py:attribute:: unique_together :type: ClassVar[list[list[str]]] :value: [['ca', 'crl_number']] .. py:attribute:: indexes :type: ClassVar[list[django.db.models.Index]] .. py:method:: raise_invalid_signature_error() Raises a ValidationError indicating an invalid CRL signature. .. py:method:: create_from_pem(ca, crl_pem, *, set_active = True, next_update_delta = None) :classmethod: Creates a new CRL from PEM data. :param ca: The CA that issued this CRL. Can be None for CRLs not associated with a CA. :param crl_pem: The CRL in PEM format. :param set_active: If True and ca is provided, deactivates other CRLs for this CA and sets this as active. :param next_update_delta: Optional timedelta to override the CRL's nextUpdate field. If provided, sets nextUpdate to thisUpdate + delta. :returns: The newly created CRL model. :rtype: CrlModel :raises ValidationError: If the CRL is invalid or doesn't match the CA. .. py:method:: get_crl_as_crypto() Returns the CRL as a cryptography CertificateRevocationList object. :returns: The CRL. :rtype: x509.CertificateRevocationList :raises ValidationError: If the CRL cannot be parsed. .. py:method:: get_revoked_serial_numbers() Returns a set of revoked certificate serial numbers. :returns: Set of revoked serial numbers. :rtype: set[int] .. py:method:: is_certificate_revoked(serial_number) Checks if a certificate with the given serial number is revoked. :param serial_number: The certificate serial number to check. :returns: True if the certificate is revoked, False otherwise. :rtype: bool .. py:method:: is_expired() Checks if this CRL has expired based on nextUpdate. :returns: True if the CRL has expired, False otherwise. :rtype: bool .. py:property:: days_left :type: int Returns number of days from now until next_update. If expired or no next_update, returns 0. .. py:method:: get_validity_hours() Returns the validity period in hours. :returns: The validity period in hours, or None if not set. :rtype: float | None .. py:method:: save(*args, **kwargs) Override save to validate before saving. .. py:method:: pre_delete() Called before deleting the model.