Closed jsfrerot closed 4 years ago
You aren't telling the TLSSocket what hostname to negotiate since you are passing an IP.
The following:
connection = tls.TLSSocket('10.4.32.37', 443, session=session)
should be:
connection = tls.TLSSocket('umi-mobile.net', 443, session=session)
if I put "umi-mobile.net" it will resolve to the public IP address which is hosted on the haproxy loadbalancer. That's why I need to put the internal IP in the socket. Then I pass the hostname I want to validate in validate_tls. Is there another way of doing this ?
Yes, this should do it:
timeout = 10
connection = tls.TLSSocket.wrap(
socket.create_connection(('10.4.32.37', 443), timeout),
'umi-mobile.net',
session=session
)
This will allow you to create the socket to whatever server you want, then have TLSSocket initiate the TLS handshake using the specified hostname.
That did the trick ! Thank you.
Hi, I'm trying to validate certificate using SNI (as I have more than 1 certificate for the same vhost in nginx), but it doesn't seem to work properly:
and openssl says it's ok
What am I doing wrong here ?