Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/x509: generate serial number for nil template SerialNumber #67675

Open
rolandshoemaker opened this issue May 28, 2024 · 5 comments
Open
Labels
Proposal Proposal-Accepted Proposal-Crypto Proposal related to crypto packages or other security issues
Milestone

Comments

@rolandshoemaker
Copy link
Member

Serial number generation is painfully complicated, especially if you want spec compliance. We've seen, over and over, that people get this wrong, even when trying to get it right.

We should provide an extremely simple way for people to get a correct serial easily. I propose that if the template passed to CreateCertificate contains a nil SerialNumber (currently an error), we will generate a conformant serial number, and add the following to the CreateCertificate documentation:

// If template.SerialNumber is nil, a serial number will be generated which
// conforms to RFC 5280, Section 4.1.2.2 using entropy from rand.

This is similar to, but somewhat different from, #52444. Either both, or just this proposal, could be implemented (the same logic would be used in both places).

@gopherbot gopherbot added this to the Proposal milestone May 28, 2024
@ianlancetaylor ianlancetaylor added the Proposal-Crypto Proposal related to crypto packages or other security issues label May 28, 2024
@AGWA
Copy link

AGWA commented May 29, 2024

I like this more than #52444 since it requires less code to use, and doesn't require handling an additional error return. I can't think of a reason to ever generate a standalone serial number.

@rsc rsc changed the title proposal: crypto/x509: automatically generate serial if template SerialNumber is nil proposal: crypto/x509: generate serial number for nil template SerialNumber May 30, 2024
@rsc
Copy link
Contributor

rsc commented May 30, 2024

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc
Copy link
Contributor

rsc commented Jun 5, 2024

Have all remaining concerns about this proposal been addressed?

The proposal is to change CreateCertificate to handle a nil template.SerialNumber by generating a serial number according to RFC 5280, Section 4.1.2.2.

The other create routines do not take templates with serial numbers and are unaffected.

@rsc
Copy link
Contributor

rsc commented Jun 12, 2024

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

The proposal is to change CreateCertificate to handle a nil template.SerialNumber by generating a serial number according to RFC 5280, Section 4.1.2.2.

The other create routines do not take templates with serial numbers and are unaffected.

@rsc
Copy link
Contributor

rsc commented Jun 24, 2024

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

The proposal is to change CreateCertificate to handle a nil template.SerialNumber by generating a serial number according to RFC 5280, Section 4.1.2.2.

The other create routines do not take templates with serial numbers and are unaffected.

@rsc rsc changed the title proposal: crypto/x509: generate serial number for nil template SerialNumber crypto/x509: generate serial number for nil template SerialNumber Jun 24, 2024
@rsc rsc modified the milestones: Proposal, Backlog Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal Proposal-Accepted Proposal-Crypto Proposal related to crypto packages or other security issues
Projects
Status: Accepted
Development

No branches or pull requests

5 participants