I try to edit the mallory proxy which can be used to sniff SSL-traffic. However it has problems with servers using connecting to a server behing e.g. CloudFlare because one can't get the real certificate but the one from the CloudFlare server in the front.
Due to this I wanted to use the server_hostname option from SSLContext.wrap_socket(). But for this I need to get the destination server's name from the Python socket object. However the only function I know to retreive this is getpeername() but this returns only the destination's ip. Does someone know a way to get the server name from a socket, too?
The solution dhke suggested in the comments, to call set_servername_callback()
, is indeed the solution I searched for as one can see here. However it doesn't work to use this in mallory but that's another topic.