Skip to content

crypto/x509: InvalidReason.Expired is misleading for not-yet-valid certificates #76020

Description

@GenFlogi

What version of Go are you using?

1.25.3

What did you expect to see?

Different InvalidReason constants for "expired" vs "not yet valid" certificates,
as these are semantically different conditions.

What did you see instead?

Both conditions use InvalidReason.Expired, which is misleading since "expired"
in English implies something was valid but no longer is, not something that
hasn't become valid yet.

Proposal:

Add a new InvalidReason constant "NotYetValid" to distinguish between:

  • Certificates that have expired (after NotAfter)
  • Certificates that are not yet valid (before NotBefore)

This would make error handling more precise and the API clearer.

I would be happy to help implement this and to create a pull request

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions