Skip to content

[bug] renew() resets validity_end to system default, discarding original validity duration #213

Description

@devangpratap

Describe the bug

BaseX509.renew() unconditionally resets validity_end to the system default (DEFAULT_CERT_VALIDITY /DEFAULT_CA_VALIDITY), discarding the validity duration that was originally set on the certificate. This means cert created with a custom validity window (e.g. from a template) loses that window on every renewal, reverting to the system default.

Two problems in renew() (base/models.py):

  1. validity_end is overwritten with the system default instead of preserving the original duration.
  2. validity_start is never updated, leaving a stale start date after renewal.

Steps To Reproduce

  1. Create a certificate with a non-default validity duration (e.g. 730 days instead of the system default).
  2. Note validity_end - validity_start = 730 days.
  3. Call .renew() on that certificate.
  4. Observe that validity_end is now now + DEFAULT_CERT_VALIDITY (system default), not now + 730 days.

Expected behavior

renew() should preserve the original validity duration derived from validity_end - validity_start and apply it from the new validity_start, so a cert originally valid for 730 days is still valid for 730 days after renewal.

Screenshots

N/A

System Information:

  • OS: macOS 15.3
  • Python Version: Python 3.10+
  • Django Version: Django 3.2+
  • Browser and Browser Version (if applicable): N/Aa

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions