Skip to content

Improve CertificateRequest's CSR validation code - #6056

Merged
SgtCoDFish merged 1 commit into
cert-manager:masterfrom
inteon:improve_pki_webhook
Jul 11, 2023
Merged

SgtCoDFish merged 1 commit into
cert-manager:masterfrom
inteon:improve_pki_webhook

Conversation

@inteon

@inteon inteon commented May 11, 2023 •

Copy link
Copy Markdown
Member

The CSR validation code is too complex and behaves unexpectedly in some scenarios.
Simply put, we want what is encoded CSR to match what is encoded in the CertificateRequest resource.
Currently there are some gaps in this validation logic (see tests for more info).

Kind

/kind cleanup
/kind bug

Release Note

The CSR blobs in CertificateRequest resources are now validated correctly.

@jetstack-bot jetstack-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. area/testing Issues relating to testing kind/bug Categorizes issue or PR as related to a bug. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 11, 2023
@inteon
inteon force-pushed the improve_pki_webhook branch from 6f6f942 to f99b0c8 Compare May 11, 2023 09:37
@jetstack-bot jetstack-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels May 11, 2023
@inteon

inteon commented May 11, 2023

Copy link
Copy Markdown
Member Author

/retest

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 24, 2023
@inteon
inteon force-pushed the improve_pki_webhook branch from f99b0c8 to c9f90cd Compare May 25, 2023 07:47
@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2023
@inteon
inteon force-pushed the improve_pki_webhook branch 3 times, most recently from 1a64f12 to d54b604 Compare May 25, 2023 09:34
@inteon
inteon force-pushed the improve_pki_webhook branch from d54b604 to 810b301 Compare June 14, 2023 20:45

@SgtCoDFish SgtCoDFish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like the desire to refactor this and make it clearer - I'm a little scared by the unsafe and the mystery ClientAuth validation stuff though!

@inteon
inteon force-pushed the improve_pki_webhook branch 5 times, most recently from 4f73e9b to 82fa269 Compare June 27, 2023 09:11
@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 29, 2023

@SgtCoDFish SgtCoDFish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold

I don't see anything here which should block merging, but I'm leaving a hold just for the breaking changes. Feel free to unhold or make non-breaking, I don't really mind either way!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

note: This file has a bunch of breaking changes in it. I suspect not many will be using any of these functions externally to cert-manager, but any breakage feels a little icky to me and I don't think we need break people here. I don't think it's a blocker though

@jetstack-bot jetstack-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 3, 2023
@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 3, 2023
@inteon
inteon force-pushed the improve_pki_webhook branch from 82fa269 to 7f4f536 Compare July 4, 2023 07:27
@jetstack-bot jetstack-bot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 4, 2023
@inteon
inteon force-pushed the improve_pki_webhook branch from 059d960 to 8793376 Compare July 4, 2023 09:21
@inteon inteon added this to the 1.13 milestone Jul 4, 2023
@inteon
inteon force-pushed the improve_pki_webhook branch from 8793376 to a214afd Compare July 4, 2023 14:58
@jetstack-bot jetstack-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 5, 2023
@inteon

inteon commented Jul 5, 2023 •

Copy link
Copy Markdown
Member Author

I split #6199 out of this PR first.

DONE

@inteon
inteon force-pushed the improve_pki_webhook branch from e6cbfb6 to 905e0a9 Compare July 7, 2023 07:35
@jetstack-bot jetstack-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 7, 2023
@inteon
inteon force-pushed the improve_pki_webhook branch from 905e0a9 to 4d7f628 Compare July 10, 2023 10:48
@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 10, 2023
wantE: []*field.Error{},
a: someAdmissionRequest,
wantE: []*field.Error{
field.Invalid(fldPath.Child("request"), nil, "encoded CSR error: the KeyUsages [] do not match the expected KeyUsages [ 'digital signature', 'key encipherment' ]"),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This behavior is more correct, if a empty set of KeyUsages is encoded, we still want to compare it to the Usages array,

@SgtCoDFish SgtCoDFish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve
/unhold

I see no reason not to merge! My existing comments about whether or not this should be a feature gate remain, but we can merge this to move forwards in any case!

@jetstack-bot jetstack-bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jul 11, 2023
@SgtCoDFish
SgtCoDFish merged commit a76003f into cert-manager:master Jul 11, 2023
@jetstack-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inteon, SgtCoDFish

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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/testing Issues relating to testing dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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.

3 participants