Suppose I have a valid SSL certificate for my application certified by valid CA and I turn evil.

Now I want to do MITM between A and B. When I'll get a request from A, I'll send my valid SSL certificate to A and then forward A's request to B. Is this possible? I'm talking about a scenario without browsers. i.e when URL bar is not visible to the user. if this is possible then how can I prevent it for my application?

  • Remember that the cert is tied to a domain name. Are you accounting for that? Does the app use certificate pinning? HSTS? Certificates are handed out to everyone who visits a site because they are public. Did you mean having the CSR or the private key?
    – schroeder
    Commented Aug 18, 2020 at 14:42

2 Answers 2


When I connect to a website, say https:/ /www.goodguys.com, then my computer and the website do two things: One, they negotiate how to encrypt their communications. Two, the server sends me unforgeable evidence that it is indeed www.goodguys.com.

The goodguys have received from their CA the keys needed to prove that they are www.goodguys.com. You may have received from your CA the keys needed to prove that you are www.evilhackers.com. That's why your MITM attack will fail: You can only prove that you are evilhackers, not goodguys. So my computer will reject your server. No chance.

What can you do: You can break into the goodguys' server and steal their keys. That's why these keys need to stay absolutely secure. With these keys, you can convince my computer that you are www.goodguys.com, and the MITM attack works. Or you can bribe an employee at the CA to give me either a copy of the keys they gave to goodguys, or just create new goodguys keys and hand them over to me. Same effect. Whatever CA does this will be found out, and most likely all the certificates they ever created will be invalidated. (My computer has a list of CAs that it accepts built in, and Microsoft/Google/Apple would remove the CA from that list. From then on, their certificates all stop working, so that CA will go out of business).

You can also create a self signed certificate. With that you can send my server the message "I'm www.goodguys.com, and you can believe that, because this message is signed by www.goodguys.com". Anyone can do that in two minutes. My computer however will say "I see this claims to be www.goodguys.com, but all I know is that whoever made the claim signed that it is true, and that proves nothing at all". Most computers will automically not accept self-signed certificates.


For you to be able to mount a MITM attack between A and B, you would need to have a valid certificate. This certificate needs a few things:

  • it must be signed by a CA trusted by A
  • it must be valid (various parameters, including valid time range)
  • it must have B's DNS name in the Subject's Common Name field, or Subject Alternative Names.

Without all three, the browser (or any other well behaving client) will refuse the connection.

It sounds like you have a certificate for an arbitrary DNS C. This would fail the third requirement, causing it to be rejected.

How to really do a MITM:

You would need to present A with a valid certificate issued to B.

For this to happen, you would need to do one of the following:

  • get around the CA checks and convince them that you really are B, issuing a valid certificate
  • have your own CA trusted by A (if you have access to my computer, you could add your own CA certificate to the list of trusted root CAs
  • break public key cryptography, allowing you to forge certificates

You must log in to answer this question.

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