-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: Include entire certificate chain if provided #1077
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
Conversation
|
I haven't yet tested this in our live environment, will be doing that shortly, but would appreciate an early review |
|
Looks sensible to me 😄 To be more sure, could you also look at adding an e2e test for this? It should be able to go in here: https://github.com/jetstack/cert-manager/blob/master/test/e2e/suite/issuers/ca/certificate.go - I think you may have to rework how the BeforeEach function works a bit, or otherwise make all of those e2e tests run with a chain as part of the signing keypair 😄 |
|
@munnerz I've updated the e2e ca to be an issuer instead of the root CA |
|
We should also extend the e2e test cases to actually check the chain is included as expected. This may need us to actually provision a few different types of issuers during tests, i.e. some with only a self signed root keypair, one with a chain, etc. (verifying the expected output afterward). Thinking about this more, in future it may be sensible for us to extend the |
|
Yeah, that's a good point. We should have more tests. And mhm, that sounds like a reasonable refactoring. I guess we could leave that for a later PR? |
|
@munnerz I've added some e2etests for this (which failed prior to the fix) |
pkg/issuer/ca/issue.go
Outdated
| } | ||
|
|
||
| // encode the chain | ||
| chainPem, err := pki.EncodeX509Chain(signerCertChain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it looks like signerCertChain includes the full chain, including the 'root' certificate. If for example the CA here is a self signed root, we'd be bundling that with all leaf certificates generated from that root.
From my understanding, this is not desired behaviour, although I may be wrong. Are there any other similar examples or info on how this usually behaves elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I don't think we need/want the self signed root. I don't think it makes any difference though - every implementation I've seen, all of the chain certs get imported into a cert pool that can be used to help verify. Importing the root there makes no difference to the outcome.
(In golang for example a verify operation has a certPool of certs that are trusted, and another certPool of arbitrary certs that can be used to form chains to the trusted ones.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how I could tell if a cert is self-signed, and exclude it from this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@munnerz I've made it so the chain will now exclude self-signed certificates. How's that?
|
@munnerz I'm not sure what happened with the tests there. The diff from my earlier version which passed the tests is minimal.. Help? |
|
🤦♂️ sorry, I've messed up your branch! |
|
/retest |
11 similar comments
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/lgtm cancel Sorry about this - didn't even realise this was going on! |
|
/test verify |
Use the standard X509 certificate validation to check that generated certificates can be validated by clients Signed-off-by: Mike Bryant <m@ocado.com>
This demonstrates that the certificates generated from an issuer 2 levels down do not validate Signed-off-by: Mike Bryant <m@ocado.com> Signed-off-by: James Munnelly <james@munnelly.eu>
Allow a user to provide an entire certificate chain to the ca issuer. Include that chain in all generated certificates Signed-off-by: Mike Bryant <m@ocado.com>
Signed-off-by: James Munnelly <james@munnelly.eu>
Signed-off-by: James Munnelly <james@munnelly.eu>
kragniz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
What this PR does / why we need it: Allow a user to provide an entire certificate chain to the ca issuer. Include that chain in all generated certificates
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close that issue when PR gets merged): fixes #1067Special notes for your reviewer:
Release note: