-
Notifications
You must be signed in to change notification settings - Fork 441
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
[Bug]: Receiving error verifying x5cInsecure certificate chain: x509: certificate specifies an incompatible key usage
only after expiry
#1843
Comments
Here's a minimal reproduce in a self-contained Dockerfile (though now I'm not getting the
|
The X5cInsecure certificate is used by step-ca to renew certificates without using mTLS, usually expired certificates. Certificate.Verify defaults to require ServerAuth if no KeyUsages is set as an option. But due to how these tokens are used, it makes more sense to require only ClientAuth. Related to smallstep/certificates#1843
Oooh, so because the certificate is expired authentication uses X5CInsecure with JWT instead of mTLS, which is what triggers this codepath? |
@andsens exactly 🙂 |
Hi @andsens, I've just pushed a commit to the master branch that fixes this issue. Due to this bug, there's a slight change in behavior. Without ClientAuth, a certificate cannot renew itself using mTLS, but this bug allowed the certificate to be renewed using the X5CInsercure flow, used for expired certificates or |
But that's fine, the client cert has client auth:
:-D |
I made a Dockerfile for an easy reproduce in the next comment.
Steps to Reproduce
So I'm trying to create an authority for issuing and renewing Kubernetes client certificates in k3s. To that end I am hostpath mounting the k3s client-ca into step-ca and specifying it both as root and intermediate.
The template is configured so that the subject cannot be changed:
To bootstrap it all, the first cert is issued by running
step certificate create
using an inline template.To renew certificates I added an X5C provisioner with the same client-ca. The relevant parts of the config look like this:
The bootstrapped certificate works and I am even able to renew it with the CA when the client certificate is still valid. However, once the certificate has expired,
step ca renew --force system:admin.crt system:admin_key
fails on the server with:client output:
A client cert looks like this:
The kubernetes client ca looks like this:
(Note that there is no PathLength restriction, so setting it as root should be OK I believe)
Your Environment
step-ca
Version - 0.26.1Expected Behavior
Since
allowRenewalAfterExpiry
istrue
, the certificate should be renewed.Actual Behavior
The certificate renewal request fails.
Additional Context
So far I have traced the error from
renew.go
, throughauthorize.go
tocrytpto/jose/parse.go
, tozcrypto/x509/verify.go
(the only place I found that actually returnsIncompatibleUsage
) tocheckChainForKeyUsage()
in that same file.Now, at first glance this seems to be similar to smallstep/cli#467, but no certificates involved in the defaults templates from
step ca init
specify the ServerAuth ext key usage either, so obviously I'm reading some code wrong. Additionally, the date check happens after the key usage check, which confuses me even more as to how that error is the one I'm seeing. All in all, I really tried to see what I'm doing wrong or how I can work around a potential limitation, but I'm just not grok'ing the code well enough to follow the thread.Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
p,s,: What I'm trying to do is an ideal use-case for #186 btw. Right now I'm running a separate step-ca to issue SSH/HTTP certs etc.
The text was updated successfully, but these errors were encountered: