From 47190f3c831f16fedcb0072811ebe5aad920c1c9 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Tue, 14 May 2024 12:15:09 -0700 Subject: [PATCH] Require ClientAuth when verifying an X5cInsecure certificate 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 --- jose/parse.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jose/parse.go b/jose/parse.go index 9807af03..760c4f16 100644 --- a/jose/parse.go +++ b/jose/parse.go @@ -267,6 +267,9 @@ func ParseX5cInsecure(tok string, roots []*x509.Certificate) (*JSONWebToken, [][ Intermediates: interPool, // A hack so we skip validity period validation. CurrentTime: leaf.NotAfter.Add(-1 * time.Minute), + KeyUsages: []x509.ExtKeyUsage{ + x509.ExtKeyUsageClientAuth, + }, }) if err != nil { return nil, nil, errors.Wrap(err, "error verifying x5cInsecure certificate chain")