My project is to find out how to detect HTTPS interception/mitm and create some sort of application using detection techniques. One of the ways I was thinking of is a active desktop application to listen in on the connections between client and server to check the authenticity of SSL certificates using the certificate fingerprint. Is it possible to create a desktop application in python (or any other language) to detect HTTPS interception using the sites SSL certificate fingerprinting?

Taking a look at this page https://www.grc.com/fingerprints.htm, it seems quite possible to do so.

I understand that browsers are likely to have built-in technologies to do this but this is something that is part of my research and development project.

3 Answers 3


There is a mechanism called Certificate Transparency. It is based on a system of public logs of issued certificates. Here you can red how it works.

MITM can have different reasons. For instance, some organizations (in different fields - in education, public sector, some also in business) pre-install their CA certificates on all devices of their users and issue certificates for any servers the users want to access. For any TLS connection a proxy presents a certificate that they have just generated. Browsers consider such certificates as trusted because it is issued by a CA whose certificate is pre-installed and thus considered trusted. Then proxy server sends a request to the target server. Thus on the proxy level the organization can read the requests and responses, i.e. the whole traffic.

But it will be impossible to register such certificates in the public logs. E.g. Facebook would be informed that some organization is trying to register a certificate for Facebook domain and would not allow to do that. That's why organizations that employ such MITM method don't even try to register such certificates.

Another example is the case when an attacker has broken a part of CA system (stolen the needed private key etc.) and issued a technically valid certificate for some domain. In such case the domain owner would be informed that there is an attempt to register a new certificate for the domain. The owner would check it and would report such certificate as fraud. Thus the usage of such certificate will be impossible (if you apply CT technique).

  • I once looked at this and discovered it would give way if you tried fully automated defenses. Basically, an untrustworthy root can completely synthesize a false certificate transparency result for that root. If it's also the root that's signing the MITM certs ... It would be obvious to a human that something's wrong here but I couldn't come up with a way to detect it other than hardcoding the list of public roots, and if I could do that I could bail the connections directly.
    – Joshua
    Mar 28, 2021 at 22:24
  • 1
    1) "hardcoding the list of public roots" - this is what many software does. For instance, OS (Windows, Linux, Mac) installs includes a list of trusted CA certificates. Also browsers like FrieFox do that. Also Java Runtime is shipped with a set of trusted CA certificates.
    – mentallurg
    Mar 28, 2021 at 23:53
  • 1
    2) Some browsers do check CT logs automatically, some don't.
    – mentallurg
    Mar 28, 2021 at 23:53
  • 1
    3) "an untrustworthy root can completely synthesize a false certificate transparency result" - Yes. But you can access the same sites when you are not in the manipulated network and you can see the real certificates and real CT logs.
    – mentallurg
    Mar 28, 2021 at 23:53
  • And if you can arrange for your answer to 3) you weren't playing the same game I was.
    – Joshua
    Mar 29, 2021 at 0:18

The term you may be looking for is probably 'certificate pinning'.

If the application is doing the TLS connection, it should simply validate the certificate on its own. It doesn't need to check the certificate against the system trust store. It can simply validate the certificate against one it has internally hardcoded.

(This would be the strongest for validation, although I would recommend checking instead that it is signed by its own root, as hardcoding the certificate means you can never change it, even if compromised, whereas if you check that it is signed by your own certificate root you have stored offline, you could create a new one and rotate it)

A program that bundled its own server certificate will be immune to MITM (as in, it will be unable to connect). Of course, the user of the program could change the executable by modifying the embedded certificate, or simply patch the routine doing the validation. You can't defend from that.

For your research project look up how, years ago, Google Chrome detected MITM taking place for sites like google.com and gmail.com, since it knew about the CA those sites should be using long before HTTP Public Key Pinning existed.


... application to listen in on the connections between client and server to check the authenticity of SSL certificates using the certificate fingerprint.

While it would be possible to intercept the connection for example by creating a proxy or by doing packet captures it might not be possible to get the certificate for the connection in order to compute the fingerprint. While with TLS 1.2 and lower the certificate is contained in the TLS handshake in plain and can thus be extracted, it gets only transferred encrypted in TLS 1.3 and can not be extracted. Additionally no certificate is even transmitted when TLS sessions gets resumed. This means that the approach of intercepting and checking traffic will in many cases not work.

A different approach would be to not intercept connections but instead to connect directly using the application to selected hosts and check the certificate, in the hope that if MITM is done against the browser at least one of these connections from the application will be intercepted too. TLS connections can be easily created with Python and it is also easy to extract the certificate from the connection then and compute the fingerprint - but this is a pure programming task and off-topic here.

  • Should I post in Stack Overflow then?
    – LtMuffin
    Mar 28, 2021 at 18:12
  • @LtMuffin: It is expected that you show a specific problem when posting in stackoverflow.com and also show what you've tried. Posting the question as it is is too broad. Maybe learn first how to create a TLS client with Python and how to get the server certificate from the connection - there are many examples about this on the internet and also in the official documentation of the Python ssl module. Mar 28, 2021 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .