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

Command

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.BaseCommand

Management command to check for expiring or expired certificates.

Expiring certificates trigger a WARNING notification, while expired certificates trigger a CRITICAL notification.

help = 'Check for expiring or expired certificates.'[source]
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:
Return type:

None