How to check what certificate is being used in the

2019-08-20 09:33发布

I have a web site written in PHP and I want to be sure that my visitors use my SSL certificate, I mean I want to be sure that there is no man in the middle. How I'll do it?

Edit: Any trick to send certificate name from POST or GET?

Edit: Or I'll send a hash to a user computer, the user computer will hash the cert name with a javascript, and compare both of them whether they mach or not. Not best solution but better than nothing.

标签: php ssl
3条回答
SAY GOODBYE
2楼-- · 2019-08-20 10:12

You cannot do that: MitM attack is based on the fact that the person between server and valid client already has all the valid certificates. So for your server he behaves like any other valid client.

查看更多
放我归山
3楼-- · 2019-08-20 10:12

Assuming that there is a man in the middle, all information that "your visitor" provides (which you might somehow use to identify what certificate they are using) would actually be information that the man in the middle provides. That means you cannot trust it (which is a good rule of thumb really even when there is no MITM).

In other words, this is not possible.

Another way you could reach this conclusion is this: if this were somehow possible, "man in the middle" would not be a term we all know today.

查看更多
混吃等死
4楼-- · 2019-08-20 10:13

As @Jon and @zerkms have already said, it's the client's responsibility to check the server certificate.

One way you could make sure, as a server, that the client is using a connection that has presented your server certificate is to request client-certificate authentication. Indeed, during the handshake with a client certificate, the CertificateVerify TLS message contains the signature of a digest of all the handhsake messages that have been exchanged so far, including the server certificate. If the TLS handhsake succeeds, the client will have sent the correct signature, verifiable against its certificate.

Of course, from the server point of view, this only works if you trust the client certificate.

This wouldn't completely solve the problem, in particular because it's not advisable for a client to accept to authenticate using its certificate against a server it cannot verify (even if the private key wouldn't be leaked, the identity of the certificate would be sent to the rogue party).

Again, at the end of the day, it's still the user's responsibility to decide whether it trusts the identity of the server.

查看更多
登录 后发表回答