Skip to content

crypto/x509: add ExtKeyUsage.OID #75325

@AGWA

Description

@AGWA

(updated 2025-09-15)

x509.Certificate currently uses these fields to convey a parsed certificate's Extended Key Usage (EKU) values:

ExtKeyUsage        []ExtKeyUsage           // Sequence of extended key usages
UnknownExtKeyUsage []asn1.ObjectIdentifier // Encountered extended key usages unknown to this package.

There is currently no way to write future-proof code that checks for an unsupported EKU in a certificate. Checking UnknownExtKeyUsage alone is not sufficient because if the EKU becomes supported in the future, it will no longer appear in UnknownExtKeyUsage. And there's no way to check ExtKeyUsage because it's an int, not an OID, and there's no way to know what value the EKU will be assigned in the future.

TesseraCT for example is resorting to parsing the EKU extension itself to avoid this gotcha.

To make it possible for code to check for an OID in both UnknownExtKeyUsage and ExtKeyUsage, we propose adding:

// OID returns the ASN.1 object identifier of the EKU.
func (eku ExtKeyUsage) OID() OID

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposalProposal-AcceptedProposal-CryptoProposal related to crypto packages or other security issues

    Type

    No type

    Projects

    Status

    Accepted

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions