I'm using http.client.HTTPSConnection to generate an HTTPS connection to my server. I cannot use the original hostname to connect to the server since this is a test setup but I need to do a proper TLS handshake with the right hostname as SNI. How do I set the SNI for the client hello of the HTTPS connection?
Judging from ssl.SSLSocket.server_hostname, if I could access the underlying socket I should be able to set server_hostname on it to the value I want. HTTPSConnection does indeed have a sock member, but it is None after construction.
In case more source code context is helpful, I'm working on the test proxy in proxy-verifier. See proxy_http1.py#L94
hostparameter passed to HTTPSConnection, the first parameter. In my case that is an IP address and must be. Well, "must" is a strong word, but for this setup it's not easy for me to modify DNS behavior to target my test box from arbitrary hostnames. But I require, independent of that, to specify the SNI for the TLS handshake. That sounds like a reasonable thing to desire and, indeed, this test requires it. Is there a way to make that happen with HTTPSConnection? Thanks for the dialog.