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
certloader: Correctly support RequestClientCert in WatchedClientConfig #26812
Conversation
Went with release-note/misc since it seems the only user of the modified method (within cilium/cilium) is in our tests. |
This is technically a bug, marking for backport to v1.14 and v1.13 as per our backport policy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch, LGTM but I'd like to see a simple unit test added for this change please.
Only configure GetClientCertificate if client keypair is configured, allowing servers to Request ClientCertificates without requiring them. In docs for `GetClientCertificate` it specifies: > GetClientCertificate must return a non-nil Certificate. If > Certificate.Certificate is empty then no certificate will be sent to the > server. If a nil certificate is sent when the server requests a client certificate, the client will return an error. Instead, only configure GetClientCertificate if certificates are provided and the server may choose to how to handle the lack of a client certificate. This is needed primarily for when the server is using RequestClientCert, which requests a certificate, but does not require the client to send one. Previously, you would see this log message: ``` transport: authentication handshake failed: mTLS client certificate requested, but not provided ``` Now, if a server requires a client certificate it should reject the TLS connection and the client will receive the error from the server. Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
2d16f87
to
2d4e4d9
Compare
@kaworu good point. I wrote a simple unit test verifying GetClientCertificate is nil when no keypair is provided. I considered doing an httpserver test, but wasn't sure that much was needed since this behavior is well documented and should be tested in the stdlib. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any context for the package, so please go ahead with getting this merged based on reviews from the Hubble folks.
Only configure GetClientCertificate if client keypair is configured, allowing servers to Request ClientCertificates without requiring them.
In docs for
GetClientCertificate
it specifies:If a nil certificate is sent when the server requests a client certificate, the client will return an error. Instead, only configure GetClientCertificate if certificates are provided and the server may choose to how to handle the lack of a client certificate.
This is needed primarily for when the server is using RequestClientCert, which requests a certificate, but does not require the client to send one.
Previously, you would see this log message produced by the clients using
WatchedClientConfig.GetClientCertificate
:Now, if a server requires a client certificate it should reject the TLS connection and the client will receive the error from the server.
I also discovered the same issue in Hubble CLI here: cilium/hubble#1123, though it doesn't use this package.