-
Notifications
You must be signed in to change notification settings - Fork 3k
Change self signed certificates to not include extended key usage #311
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
Comments
the goal was to prevent that cert from being used as a client certificate |
@liggitt is this then an invalid way to use the certificates or can the key usage for the CA be changed? https://github.com/kubernetes-incubator/service-catalog/blob/5f4ca01ed86bd5e11a64390bcd3031767477ca63/contrib/hack/start-server.sh#L55 |
The NSS encryption library does not allow a CA to be used with the extended key usage present, at least in the way we are currently doing so. The generated self signed certificates extension section looks like: ... X509v3 extensions: X509v3 Key Usage: critical Digital Signature, Key Encipherment, Certificate Sign X509v3 Extended Key Usage: TLS Web Server Authentication X509v3 Basic Constraints: critical CA:TRUE X509v3 Subject Alternative Name: DNS:localhost, IP Address:127.0.0.1, IP Address:127.0.0.1 Testing with the extended key usage removed allows curl to work, but simply switching to wget will allow integration tests to work on Fedora immediately. Related issue: kubernetes/client-go#311
The NSS encryption library does not allow a CA to be used with the extended key usage present, at least in the way we are currently doing so. The generated self signed certificates extension section looks like: ... X509v3 extensions: X509v3 Key Usage: critical Digital Signature, Key Encipherment, Certificate Sign X509v3 Extended Key Usage: TLS Web Server Authentication X509v3 Basic Constraints: critical CA:TRUE X509v3 Subject Alternative Name: DNS:localhost, IP Address:127.0.0.1, IP Address:127.0.0.1 Testing with the extended key usage removed allows curl to work, but simply switching to wget will allow integration tests to work on Fedora immediately. Related issue: kubernetes/client-go#311 (Also make sure when testing new certificates to delete certificates previously generated in .var/run/kubernetes-service-catalog/. Existing certificates are not overwritten if they already exist.)
The NSS encryption library does not allow a CA to be used with the extended key usage present, at least in the way we are currently doing so. The generated self signed certificates extension section looks like: ... X509v3 extensions: X509v3 Key Usage: critical Digital Signature, Key Encipherment, Certificate Sign X509v3 Extended Key Usage: TLS Web Server Authentication X509v3 Basic Constraints: critical CA:TRUE X509v3 Subject Alternative Name: DNS:localhost, IP Address:127.0.0.1, IP Address:127.0.0.1 Testing with the extended key usage removed allows curl to work, but simply switching to wget will allow integration tests to work on Fedora immediately. Related issue: kubernetes/client-go#311 (Also make sure when testing new certificates to delete certificates previously generated in .var/run/kubernetes-service-catalog/. Existing certificates are not overwritten if they already exist.)
I didn't realize that Fedora 27 was switching crypto libraries for curl to OpenSSL. Given that curl with NSS was the only problematic scenario, I'm closing this. |
@liggitt may I ask why autogenerated /var/lib/kubelet/pki/kubelet.crt includes the CA:TRUE if the certificate cannot be used as a CA as per https://bugzilla.mozilla.org/show_bug.cgi?id=1049176?
|
If it doesn't, go will not allow specifying the cert as a trust root |
@liggitt please correct if I misunderstand. As in Switch to wget for integration apiserver checks (#1384), the certificate includes the certificate extensions below.
Based on RFC 3280, as Extended Key Usage extension is there, the certificate can be only used for a server certificate but cannot be used for CA certificate?
I think the point in SEC_ERROR_INADEQUATE_CERT_TYPE when root CA cert has extendedKeyUsage set which was originally cited by @jpeeler stating "it can't be used to issue certificates." indicates it cannot be used as a CA certificate.
Therefore, it looks to me, having CA:TRUE will not have any effect. So I wonder why it is there.
If the intention is to use the certificate both for CA and also TLS server certificate, then perhaps ** anyExtendedKeyUsage** could be required which may allow applications (curl in the original problem statement) to accept the cert as CA? I suppose the wget behaviour of accepting the certificate as CA cert could be incorrect and the curl behaviour rejecting would be correct. If above makes sense, could you reconsider the original request of "not include extended key usage"? For myself, /var/lib/kubelet/pki/kubelet.crt has the same and I cannot use it as CA cert to talk to kubelet. |
Automatic merge from submit-queue (batch tested with PRs 59463, 59719, 60181, 58283, 59966). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Split self-signed cert and CA The key usage limitation of TLS Server Auth makes the cert invalid as a CA. This switches to generate a single-use CA, uses it to sign the serving cert, then appends the CA to the cert bytes. * allows a client to continue to reference the cert file as a trust bundle, which now contains a valid CA cert * continues to keep the generated certificate valid only for serving purposes Fixes kubernetes/client-go#311 ```release-note NONE ```
Automatic merge from submit-queue (batch tested with PRs 59463, 59719, 60181, 58283, 59966). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Split self-signed cert and CA The key usage limitation of TLS Server Auth makes the cert invalid as a CA. This switches to generate a single-use CA, uses it to sign the serving cert, then appends the CA to the cert bytes. * allows a client to continue to reference the cert file as a trust bundle, which now contains a valid CA cert * continues to keep the generated certificate valid only for serving purposes Fixes #311 ```release-note NONE ``` Kubernetes-commit: 5d144152e4d07f3752c05ec24e31d840adcd90a2
Automatic merge from submit-queue (batch tested with PRs 59463, 59719, 60181, 58283, 59966). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Split self-signed cert and CA The key usage limitation of TLS Server Auth makes the cert invalid as a CA. This switches to generate a single-use CA, uses it to sign the serving cert, then appends the CA to the cert bytes. * allows a client to continue to reference the cert file as a trust bundle, which now contains a valid CA cert * continues to keep the generated certificate valid only for serving purposes Fixes #311 ```release-note NONE ``` Kubernetes-commit: 5d144152e4d07f3752c05ec24e31d840adcd90a2
Automatic merge from submit-queue (batch tested with PRs 59463, 59719, 60181, 58283, 59966). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Split self-signed cert and CA The key usage limitation of TLS Server Auth makes the cert invalid as a CA. This switches to generate a single-use CA, uses it to sign the serving cert, then appends the CA to the cert bytes. * allows a client to continue to reference the cert file as a trust bundle, which now contains a valid CA cert * continues to keep the generated certificate valid only for serving purposes Fixes kubernetes#311 ```release-note NONE ``` Kubernetes-commit: 5d144152e4d07f3752c05ec24e31d840adcd90a2
Automatic merge from submit-queue (batch tested with PRs 59463, 59719, 60181, 58283, 59966). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Split self-signed cert and CA The key usage limitation of TLS Server Auth makes the cert invalid as a CA. This switches to generate a single-use CA, uses it to sign the serving cert, then appends the CA to the cert bytes. * allows a client to continue to reference the cert file as a trust bundle, which now contains a valid CA cert * continues to keep the generated certificate valid only for serving purposes Fixes kubernetes#311 ```release-note NONE ``` Kubernetes-commit: 5d144152e4d07f3752c05ec24e31d840adcd90a2
Uh oh!
There was an error while loading. Please reload this page.
The current code specifies server auth:
client-go/util/cert/cert.go
Line 155 in 82aa063
The problem is the current self generated certificates do not work with curl (on Fedora):
Removing the extended key usage allows everything to work as expected. Since these are for self signed certificates, I am hoping that the removal isn't a security issue. Some potentially relevant links:
https://tools.ietf.org/html/rfc5280#section-4.2.1.12
https://bugzilla.mozilla.org/show_bug.cgi?id=1049176
google/stenographer#124
(?) golang/go#11087
The text was updated successfully, but these errors were encountered: