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 a TLS client certificate by default #453

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Conversation

aead
Copy link
Member

@aead aead commented Mar 13, 2024

This commit changes the ClientAuth type from
RequestClientCert to RequireAnyClientCert by default.

In general, a KES server should demand a client certificate. Otherwise, a client (the HTTP/TLS stack) may choose to not send a client certificate - even if one is available. For example, the HTTP stack may try to be smart and not send a client certificate if it determines that cannot be validated since its self-signed.

Instead, the KES server's TLS should abort the handshake if the client does not send a certificate. However, in some cases we cannot enforce this. In particular, when some APIs should be accessible without TLS authentication, like /v1/metrics. In these cases, we have to make it optional for clients to send a certificate. However, disabling auth for some APIs is an advanced use case intended only for users who are aware of the implications.

This commit changes the `ClientAuth` type from
`RequestClientCert` to `RequireAnyClientCert` by default.

In general, a KES server should demand a client certificate.
Otherwise, a client (the HTTP/TLS stack) may choose to not
send a client certificate - even if one is available. For example,
the HTTP stack may try to be smart and not send a client certificate
if it determines that cannot be validated since its self-signed.

Instead, the KES server's TLS should abort the handshake if the client
does not send a certificate. However, in some cases we cannot enforce
this. In particular, when some APIs should be accessible without TLS
authentication, like `/v1/metrics`. In these cases, we have to make
it optional for clients to send a certificate. However, disabling
auth for some APIs is an advanced use case intended only for users
who are aware of the implications.

Signed-off-by: Andreas Auernhammer <[email protected]>
Copy link

@ravindk89 ravindk89 left a comment

Choose a reason for hiding this comment

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

I don't see any obvious issues, but I also am not sure how to test this, so take my approval with a grain of salt.

Comment on lines +308 to +320
// If mTLS authentication is disabled for at least one API,
// we must no longer require that a client sends a certificate.
// However, this may cause authentication errors when a client
// (the client's HTTP/TLS stack) does not send a certificate
// for an API that requires authentication.
if api.InsecureSkipAuth.Value {
if clientAuth == tls.RequireAnyClientCert {
clientAuth = tls.RequestClientCert
}
if clientAuth == tls.RequireAndVerifyClientCert {
clientAuth = tls.VerifyClientCertIfGiven
}
}

Choose a reason for hiding this comment

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

@aead just to confirm, how exactly would someone disable auth for an API? I don't recall this in the server config options off the top of my head.

Copy link
Member Author

Choose a reason for hiding this comment

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

@harshavardhana harshavardhana merged commit 2f5a124 into master Mar 13, 2024
7 checks passed
@harshavardhana harshavardhana deleted the tls-auth-types branch March 13, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants