Skip to content

Conversation

@mikebryant
Copy link
Member

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 #1067

Special notes for your reviewer:

Release note:

It is now possible to include a certificate chain in the secret for the `ca` Issuer. This will then be propagated to generated certificates.

@jetstack-bot jetstack-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 14, 2018
@jetstack-bot jetstack-bot requested a review from wallrj November 14, 2018 11:02
@jetstack-bot jetstack-bot added area/ca Indicates a PR directly modifies the CA Issuer code dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. and removed dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. labels Nov 14, 2018
@mikebryant
Copy link
Member Author

I haven't yet tested this in our live environment, will be doing that shortly, but would appreciate an early review

@munnerz
Copy link
Member

munnerz commented Nov 14, 2018

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 😄

@jetstack-bot jetstack-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 14, 2018
@mikebryant
Copy link
Member Author

@munnerz I've updated the e2e ca to be an issuer instead of the root CA

@munnerz
Copy link
Member

munnerz commented Nov 14, 2018

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 IssueResponse struct we use internally to have a Chain field, to allow cert-manager's core Certificate controller populate the secret (instead of misusing the Certificate field like we currently do).

@mikebryant
Copy link
Member Author

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?

@jetstack-bot jetstack-bot added dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. and removed dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 14, 2018
@mikebryant
Copy link
Member Author

@munnerz I've added some e2etests for this (which failed prior to the fix)

@mikebryant mikebryant changed the title WIP: feat: Include entire certificate chain if provided feat: Include entire certificate chain if provided Nov 15, 2018
@jetstack-bot jetstack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 15, 2018
}

// encode the chain
chainPem, err := pki.EncodeX509Chain(signerCertChain)
Copy link
Member

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?

Copy link
Member Author

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.)

Copy link
Member Author

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...

Copy link
Member Author

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?

@mikebryant
Copy link
Member Author

@munnerz I'm not sure what happened with the tests there. The diff from my earlier version which passed the tests is minimal.. Help?

@munnerz munnerz added this to the v0.6 milestone Nov 28, 2018
@jetstack-bot jetstack-bot added dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. and removed dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. labels Nov 29, 2018
@munnerz
Copy link
Member

munnerz commented Nov 29, 2018

🤦‍♂️ sorry, I've messed up your branch!

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

11 similar comments
@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@munnerz
Copy link
Member

munnerz commented Dec 10, 2018

/lgtm cancel

Sorry about this - didn't even realise this was going on!

@jetstack-bot jetstack-bot removed the lgtm Indicates that a PR is ready to be merged. label Dec 10, 2018
@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 8, 2019
@kragniz
Copy link
Contributor

kragniz commented Jan 9, 2019

/test verify

mikebryant and others added 5 commits January 9, 2019 11:39
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>
@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 9, 2019
Copy link
Contributor

@kragniz kragniz left a comment

Choose a reason for hiding this comment

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

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 9, 2019
@jetstack-bot jetstack-bot merged commit 4da8dab into cert-manager:master Jan 9, 2019
@mikebryant
Copy link
Member Author

@munnerz @kragniz Thanks for your help getting this in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/ca Indicates a PR directly modifies the CA Issuer code dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to include issuer's issuer using the ca issuer

5 participants