-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support for custom TLS ServerName or VerifyPeerCertificate function #2779
Comments
Hmm, from what I know, isn't it the usual practice that the HTTPS connections terminate on the load balancer? The communication between it and the service can then be handled separately, often done over plaintext HTTP, if the service and load balancer are in the same network 🤔 In any case, the Adding something like a new global k6 option However, there might be an easier way to implement this that won't introduce a new k6 option or wait for a completely new HTTP client API. I think we can just expand the already existing export const options = {
hosts: {
"foo.internal": "foo.us-east-1.aws.com",
},
};
export default function() {
http.get("https://foo.internal");
} There would still be the matter of trusting self-signed For now, until any of these things are actually done, you (and anyone else that stumbles on this issue) can use the This setup still seems quite unusual to me, so if anyone else has the same or a similar problem, please chime in this issue and explain your use case 🙏 This will help us to understand what the priority of this is and what the various use cases we might need to cover are. |
Actually, (sorry poor wording), the Load Balancer terminates TLS. The certificate CN just mismatch the requested Host.
Got it, thanks for all the details 👍!
That makes sense. I personally like the xk6 module option as it abstracts away low-level complexity to the developer and prevents some misconfiguration. It helps to keep the load test script to a minimum. I'd also imagine that any Go logic would run faster than if written in JS, especially if there is some kind of crypto operation or extra network call involved (eg OCSP support).
In my case,
Yes, it's a bit unusual 😅 . All things considered, I'll be looking at updating the Load Balancer certificate to include Subject Alternative Names, which should fix the hostname mismatch and make the infra setup a bit more standard 👍 I will also be using TLS Skip Verify for now. Thanks a lot for your help and all the details again, that should solve my issue! Last 2cents, I think having the ability to customize the TLS Config and the HTTP Client or Transport can be helpful to developers who might have to deal with non-standard infrastructures and proxies. The module approach looks best as it lets users add their own functions (say |
Feature Description
Problem
The k6 client targets internal services which don't reply with the same x509 CN/SAN domain as the one passed in the HTTP Request. This internal domain can not be resolved by the k6 client, who has to use the load balancer address.
This leads to a domain mismatch between the request and the response, and a failing TLS peer verification.
I have seen TLSAuth feature but it seems to be used to assign the right certificate to the connection, I don't think it would help in this case as the certificate CN would still mismatch. Besides, as documented in the code, it is going to be deprecated in the next release or so.
Suggested Solution (optional)
Solution 1: Override
ServerName
The first obvious, and most straightforward solution is to override tls.Config.
ServerName
in the request.We can potentially do that by providing a new k6 Option to override ServerName for specific TLSAuth.Domain.
I would imagine the user interface such as:
Solution 2: Let the user pass a custom TLS Verifier via an xk6 module
In short, a custom
tls.Config{}
can be passed.For example, this lets users write their own
tls.Config.VerifyPeerCertificate()
function that best matches their infra setup.I can imagine other scenarios than this one where users would need to override more parameters of tls.Config.
The domain can be used to properly map the module to the right
http.Transport
connection.While surely a little bit more complicated, it is also the most flexible solution.
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered: