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

ca: Pass OCSP Must-Staple from CSR into generated certificate #436

Merged
merged 7 commits into from
Feb 28, 2024

Conversation

wgreenberg
Copy link
Contributor

This will allow for extensions such as OCSP stapling. Happy to add a test if desired, also I wasn't sure if it's expected to filter for specific extensions or to pass them wholesale onto the cert?

Fixes #433

@jsha
Copy link
Contributor

jsha commented Feb 24, 2024

I would prefer to look for just the Must Staple extension and set that, which is what Boulder does. It's quite dangerous to pass through arbitrary extensions from the CSR, because some extensions change the semantics of certificates in dramatic ways. Of course Pebble is a testing CA but we should still avoid creating dangerous code for someone to possibly emulate. :D

ca/ca.go Outdated
var extensions []pkix.Extension
for _, ext := range order.ParsedCSR.Extensions {
if isOCSPMustStapleExtension(ext) {
extensions = append(extensions, ext)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directly appending the extension from the CSR is still slightly dangerous, as we are directly carrying over the critical bit. Boulder has a pre-built OCSP must-staple extension, and it uses that both to detect must-staple in the CSR and include must-staple in the resulting cert. That way Boulder can guarantee that the extension is never critical.

What you have here is probably fine for Pebble, but if you want to be even safer that's a pattern you could follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah nice, I'll do that! I wasn't sure how risky the critical value was, but that makes sense.

ca/ca_test.go Outdated
}

ca.CompleteOrder(order)
log.Printf("cert: %+v", order.CertificateObject.Cert)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this log line should be replaced by parsing the resulting cert and inspecting its extensions to confirm the inclusion of must-staple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shoot, I actually didn't mean to include this file, it was just for debugging. Though I could turn it into a full test, if that seems desirable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's great to have a test for this!

@aarongable aarongable changed the title ca: Pass any CSR extensions into the generated certificate ca: Pass OCSP Must-Staple from CSR into generated certificate Feb 26, 2024
@wgreenberg
Copy link
Contributor Author

Added some unit tests and modeled this after Boulder's approach. Ready for review again!

@mcpherrinm
Copy link
Contributor

Can you rebase or merge in main please? We've merged some fixes in the last few day for pebble's CI

@wgreenberg
Copy link
Contributor Author

Should be all set

@mcpherrinm
Copy link
Contributor

thanks. A few things from the linter, otherwise lgtm

@mcpherrinm mcpherrinm merged commit 6fb4280 into letsencrypt:main Feb 28, 2024
9 checks passed
@wgreenberg wgreenberg deleted the fix-433 branch February 28, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support must-staple extension
4 participants