Cannot validate certificate hostname without SNI
See original GitHub issueI get the following error message (example.com replaced with actual website) and can’t figure out why and what to do about it:
<< Cannot establish TLS with webmail.chalmers.se:443 (sni: None): TlsException(‘Cannot validate certificate hostname without SNI’,)
Steps to reproduce the problem:
- mitmdump -vw filename
- Connect (add as proxy) with android phone and install certificate (using mitmproxy.it)
- Connect to some server
Any other comments? What have you tried so far?
It seems to work for some https-sites but not others. Examples that cause the errors are webmail.chalmers.se and m.handelsbanken.se.
System information
Mitmproxy version: 0.18.2
Python version: 3.5.2
Platform: Linux-4.7.2-1-ARCH-x86_64-with-arch
SSL version: OpenSSL 1.0.2h 3 May 2016
Linux distro: arch
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Cannot validate certificate hostname without SNI - Server Fault
I am trying to understand what's exactly happening? My guess is the certificate must be installed on the first proxy (which is installed...
Read more >Cannot validate certificate hostname without SNI
I am using 2 proxies to intercept the communication between my phone and my server. Here is my topology: phone --> proxy 1...
Read more >What is SNI? How TLS server name indication works
SNI, or Server Name Indication, is an extension for the TLS protocol to indicate a hostname in the TLS handshake. Learn more about...
Read more >Mitmweb.exe works fine, but mitmdump.exe doesn't - mitmproxy
<< Cannot establish TLS with www.google.com:443 (sni: None): TlsException('Cannot validate certificate hostname without SNI',).
Read more >Cannot validate certificate hostname without SNI · 抓包代理利器
Cannot validate certificate hostname without SNI ... 的问题。 细节详见. 【已解决】mitmproxy代理报错:Cannot establish TLS with 443 sni None ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Which client are your using? I suspect an old version of Android?
The problem is as follows: When mitmproxy connects upstream, it verifies the certificate the server presents. One part of the verification is to check if the certificate matches the hostname the client is expecting. Modern versions of TLS mandate the client to send a Server Name Indication (SNI) extension during the TLS handshake which names the expected site. However, if your client does not send a SNI extension, there’s no way for us to verify the authenticity of the server’s certificate as we don’t know which site the client is expecting and we fail the connection in the way you described. You can work around this by disabling certificate verification with
mitmproxy --insecure
- be warned that you are subject to man-in-the-middle attacks then.I have another idea to work-around this problem: a reverse-dns table in the mitmproxy config.
So, if there are a couple of IP addresses which I know ahead of time will receive requests for a particular domain name, I could put that in the mitmproxy config, like:
Then, when mitmproxy intercepts a TLS connection to 1.2.3.4, it uses the hostname foo.example.com to check the certificate, if the client did not include TLS-SNI, and it otherwise does not yet know the hostname.
Just an idea, which would help with my use case at least.