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

Add self signed Issuer type #637

Merged
merged 6 commits into from Jun 15, 2018
Merged

Conversation

munnerz
Copy link
Member

@munnerz munnerz commented Jun 7, 2018

What this PR does / why we need it:

This adds a basic self signed Issuer type, for issuing self signed Certificates.

This will be used for automatic setup of resource validation in #478

Which issue this PR fixes: fixes #84

Release note:

Add 'self signed' Issuer type

@jetstack-bot jetstack-bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 7, 2018
@jetstack-bot jetstack-bot requested a review from kragniz June 7, 2018 14:17
@jetstack-bot jetstack-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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 Jun 7, 2018
@jetstack-bot jetstack-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 8, 2018
@wallrj
Copy link
Member

wallrj commented Jun 12, 2018

/assign @wallrj

Copy link
Member

@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

Looks good @munnerz

I left a couple of comments. Please address or answer those and then feel free to merge.

@@ -9,7 +9,7 @@ Welcome to cert-manager's documentation!

cert-manager is a native Kubernetes_ certificate management controller.
It can help with issuing certificates from a variety of sources, such as
`Let's Encrypt`_, `HashiCorp Vault`_ or a simple signing keypair.
`Let's Encrypt`_, `HashiCorp Vault`_, a simple signing keypair, or self signed.
Copy link
Member

Choose a reason for hiding this comment

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

❓ Maybe link to the new self signed issuer page.

Copy link
Member Author

Choose a reason for hiding this comment

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

As the other services do not link to internal pages (but to the website of the respective service/app), I decided not to here in favour of having links below.

+-----------------------------------------------+----------------------------------------------------------------------+
| :doc:`Vault <issuers/vault/index>` | Supports issuing certificates using HashiCorp Vault. |
+-----------------------------------------------+----------------------------------------------------------------------+
| :doc:`Self signed <issuers/selfsigned/index>` | Supports issuing self signed Certificates |
Copy link
Member

Choose a reason for hiding this comment

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

s/Certificates/certificates/

The presence of the ``selfSigned: {}`` line is enough to indicate that this Issuer
is of type 'self signed'.

Once created, you should be able to Issue certificates like normal by
Copy link
Member

Choose a reason for hiding this comment

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

s/Issue/issue/

CA *CAIssuer `json:"ca,omitempty"`
Vault *VaultIssuer `json:"vault,omitempty"`
SelfSigned *SelfSignedIssuer `json:"selfSigned,omitempty"`
}
Copy link
Member

Choose a reason for hiding this comment

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

❓ Should there be validation to ensure that only one of these attributes is used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes - #478 introduces validation with a validating webhook, however in order to make setting this up seamless, we need a selfsigned issuer type too, causing a bit of a dependency cycle on our PRs 😄

s := messageErrorGetCertKeyPair + err.Error()
crt.UpdateStatusCondition(v1alpha1.CertificateConditionReady, v1alpha1.ConditionFalse, errorGetCertKeyPair, s, false)
return nil, nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

❓ This error handling doesn't seem quite right.

  • If k8sErrors.IsNotFound(err) == true, which seems to be an expected condition, we still return the error.
  • If errors.IsInvalidData(err) == true, we generate a new private key, but why would the returned secret have invalid data? Maybe add an explanatory comment above this code, if it is correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

If k8sErrors.IsNotFound(err) == true, which seems to be an expected condition, we still return the error.

We won't return an error in this case, so long as generating the private key is successful (as GenerateRSAPrivateKey will return an error, or nil, which will be captured into err)

Copy link
Member Author

Choose a reason for hiding this comment

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

If errors.IsInvalidData(err) == true, we generate a new private key, but why would the returned secret have invalid data? Maybe add an explanatory comment above this code, if it is correct.

There may be invalid data if a user has manually modified the Secret/private key (or something has happened causing it to not be parse-able)

crt.UpdateStatusCondition(v1alpha1.CertificateConditionReady, v1alpha1.ConditionTrue, successCertRenewed, messageCertRenewed, true)

return pki.EncodePKCS1PrivateKey(signeeKey), certPem, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

I expected there'd be some way for user to configure the expiry date of the renewed certificate, but I can't find it.

@munnerz Pointed me to #520

@munnerz munnerz added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. labels Jun 15, 2018
@jetstack-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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

The pull request process is described here

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

Add 'selfsigned' issuer
3 participants