Skip to content

Configurable issuer duration and renewBefore#520

Closed
vdesjardins wants to merge 2 commits intocert-manager:masterfrom
vdesjardins:cert-duration
Closed

Configurable issuer duration and renewBefore#520
vdesjardins wants to merge 2 commits intocert-manager:masterfrom
vdesjardins:cert-duration

Conversation

@vdesjardins
Copy link
Copy Markdown
Contributor

@vdesjardins vdesjardins commented Apr 28, 2018

What this PR does / why we need it:
This pull request makes possible to configure the certificate validity duration and the renewal before duration per issuer.
Which issue this PR fixes:
#437
Special notes for your reviewer:
Split from Vault issuer pull request #292

Release note:

Configurable certificate duration and renewal duration using fields Issuer.spec.duration and 
Issuer.spec.renewBefore respectively.
The CA Issuer default duration is now 90 days instead of 365 days to make all issuers more consistent when configured without explicit duration.

@jetstack-bot jetstack-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 28, 2018
@jetstack-bot jetstack-bot requested a review from kragniz April 28, 2018 04:46
@munnerz
Copy link
Copy Markdown
Member

munnerz commented Apr 28, 2018 via email

@jetstack-bot jetstack-bot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 28, 2018
@vdesjardins vdesjardins force-pushed the cert-duration branch 4 times, most recently from de26bbc to 178e943 Compare April 28, 2018 18:25
messageCertificateRenewed = "Certificate renewed successfully"

messageWarningCertificateDuration = "Certificate duration received from issuer is %s which is lower than the issuer configured duration of %s"
messageWarningScheduleModified = "Certificate renewal requested schedule cannot be honored. Specified renewBefore of %s is greater than certificate total duration of %s"
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.

This sounds like a hard error to me - perhaps rephrase to explain that we've instead changed the renewal date?

I'd also make this a non-warning (i.e. EventTypeNormal), as some users will take a warning to be an error and starting opening issues 😬

const (
errorAccountRegistrationFailed = "ErrRegisterACMEAccount"
errorAccountVerificationFailed = "ErrVerifyACMEAccount"
errorDurationInvalid = "ErrACMEDurationInvalid"
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.

Needn't be an ACME specific error. ErrDurationInvalid should suffice, and can be reused across issuers.

messageAccountVerificationFailed = "Failed to verify ACME account: "
messageAccountRegistered = "The ACME account was registered with the ACME server"
messageAccountVerified = "The ACME account was verified with the ACME server"
messageDurationInvalid = "ACME "
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.

Remove this var - it doesn't really add any context for the user. They are already aware that it is an ACME certificate. We can instead just set the conditions message to err.Error()

if err != nil {
s := messageDurationInvalid + err.Error()
a.issuer.UpdateStatusCondition(v1alpha1.IssuerConditionReady, v1alpha1.ConditionFalse, errorDurationInvalid, s)
return fmt.Errorf(s)
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.

Can get rid of s and just return err here instead.

messageKeyPairVerified = "Signing CA verified"

messageDurationInvalid = "CA "
errorDurationInvalid = "ErrCADurationInvalid"
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.

Can get rid of both of these vars

s := messageDurationInvalid + err.Error()
glog.Info(s)
c.issuer.UpdateStatusCondition(v1alpha1.IssuerConditionReady, v1alpha1.ConditionFalse, errorDurationInvalid, s)
return fmt.Errorf(s)
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.

Same comment as ACME issuer

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 2, 2018
MadVikingGod pushed a commit to MadVikingGod/cert-manager that referenced this pull request May 8, 2018
This addresses comments in PR cert-manager#520.  To make the Duration check more generic it
was moved into the Issuer factory, allowing all Issuers to benifit.
@MadVikingGod
Copy link
Copy Markdown

Hi, this is a feature that I am interested in using. Is there anything that I can do to help shepherd this along it's path?

@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2018
@vdesjardins
Copy link
Copy Markdown
Contributor Author

I just pushed an update to the pull request with fixes for the code review and support for the Vault issuer.

The main remaining issue that I can think of right now is what we should do with the ACMEv2 issuer. The ACMEv2 issuer receives a validation error from Let's Encrypt (Boulder) when a custom notBefore and notAfter is specified in the order request. The reason is that the Boulder server do not implement that particular feature of the spec.

Since Boulder (and Pebble) are the only servers implementing the ACMEv2 protocol that I'm aware of maybe we could do one of these:

  • Remove support for custom duration instead of generating an error. We could generate an status condition to let the user know that we do not support custom duration for this issuer.
  • Recover from the error and update the certificate status with a warning/info about the fact that the issuer does not support custom duration.

@munnerz munnerz added this to the v0.4 milestone May 9, 2018
@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2018
@MadVikingGod
Copy link
Copy Markdown

It's an optional field in the acme spec. I would just put it in as a warning that it's not supported by the ACME server.

@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 19, 2018
@munnerz
Copy link
Copy Markdown
Member

munnerz commented May 24, 2018

/cc @vdesjardins

@jetstack-bot
Copy link
Copy Markdown
Contributor

@munnerz: GitHub didn't allow me to request PR reviews from the following users: vdesjardins.

Note that only jetstack members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/cc @vdesjardins

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@vdesjardins vdesjardins force-pushed the cert-duration branch 2 times, most recently from 9b8e239 to ee86bb6 Compare May 30, 2018 01:14
@vdesjardins
Copy link
Copy Markdown
Contributor Author

/retest

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 9, 2018
@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 9, 2018
@jetstack-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: wallrj

Assign the PR to them by writing /assign @wallrj in a comment when ready.

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

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 15, 2018
@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 15, 2018
@jetstack-bot
Copy link
Copy Markdown
Contributor

jetstack-bot commented Jun 15, 2018

@vdesjardins: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
cert-manager-e2e-v1-9 516be06 link /test e2e v1.9

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

// Clearing the specified validity period in the request and try again
order.NotBefore = time.Time{}
order.NotAfter = time.Time{}
createdOrder, err = cl.CreateOrder(ctx, order)
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 think we need some way to mark a certification configuration as invalid in order to prevent re-processing of a Certificate in this case, instead of re-attempting to create ourselves.

This will require us somehow hashing the 'input values' (i.e. the Duration field right now) and recording on the Certificate resource that the particular configuration is invalid. When a re-sync happens (i.e. when the resource changes), we will have to compare that hash to the hash of the new resource in order to determine if a user has updated their configuration, in which case we retry CreateOrder with the new configuration.

I think there are a number of places where this could be useful, at least for ACME. Perhaps for other Issuers (or other parts of the ACME issuer) in future too. It's sort of 'runtime validation' against the actual Issuer, and not just validating the resources are valid 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree. Perhaps we can store it in a label like the hash computed by the deployment resource? In the pod resource this field is called pod-template-hash.

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.

#761 will allow us to skip processing Certificate resources with particular fields set if they reference ACME issuers.

This should allow us to just blanket not support setting these fields with all ACME issuers. We can then explore at a later time an implementation that's more complex without making a breaking change 😄

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.

#761 has now merged, so we should be able to add in this check now 😄

@vdesjardins are you still in a position to rebase and get this PR up to date? There's been a few changes that may effect your implementation slightly!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I should have some time hopefully to start looking at it the coming days!

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 26, 2018
@jetstack-bot
Copy link
Copy Markdown
Contributor

@vdesjardins: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@munnerz
Copy link
Copy Markdown
Member

munnerz commented Oct 12, 2018

Closing this in favour of #893 😄

@munnerz munnerz closed this Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants