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

Require ClientAuth when verifying an X5cInsecure certificate #503

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jose/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Comment on lines +270 to +272
Copy link
Member

Choose a reason for hiding this comment

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

Should ExtKeyUsageServerAuth be provided too, for backwards compatibility? I agree that it makes more sense to require just client auth, but there's a chance there's certs out there being used that don't have it set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. This method is used as a replacement for mTLS when this cannot be performed, and the requirement for a client to do mTLS is to have x509.ExtKeyUsageClientAuth. See
https://github.com/golang/go/blob/1f6a983baf4b9a636e9e4bbd827fcb4d6ef4ebe0/src/crypto/tls/handshake_server.go#L892-L897

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with merging it like this, but it still can be a breaking change in practice. Likely a fairly small chance, but still.

})
if err != nil {
return nil, nil, errors.Wrap(err, "error verifying x5cInsecure certificate chain")
Expand Down
Loading