commands.check_certificate_validity¶
Management command to check the validity of certificates.
This module defines a Django management command that checks for expiring or expired certificates stored in the database. Expiring certificates trigger a WARNING notification, while expired certificates trigger a CRITICAL notification. Notifications are created only if they do not already exist for the given certificate and event.
Classes¶
Management command to check for expiring or expired certificates. |
Module Contents¶
- class commands.check_certificate_validity.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]¶
Bases:
django.core.management.base.BaseCommandManagement command to check for expiring or expired certificates.
Expiring certificates trigger a WARNING notification, while expired certificates trigger a CRITICAL notification.
- handle(*args, **kwargs)[source]¶
Entrypoint for the command.Args.
- Parameters:
*args (Any) – Additional positional arguments.
**kwargs (dict[str, Any]) – Additional keyword arguments.
- Return type:
None
- _check_certificate_validity()[source]¶
Check for certificates that are expiring soon or have already expired.
Expiring certificates: Within the next 30 days. Expired certificates: Already past their not_valid_after date.
- Return type:
None
- _create_notification(certificate, event, notification_type, message_type, new_status)[source]¶
Helper function to create a notification for a certificate.
Skips notification creation if one already exists for the given event and certificate.
- Parameters:
certificate (pki.models.CertificateModel)
event (str)
notification_type (str | notifications.models.NotificationModel.NotificationTypes)
message_type (str | notifications.models.NotificationModel.NotificationMessageType)
new_status (notifications.models.NotificationStatus)
- Return type:
None