I'm working on a specific (hypothetical) situation, where I have two client machines attempting to perform a public key exchange, via a server. There's no possibility for a direct connection between the two clients, as the exchange is asynchronous.

The server cannot be completely trusted. As it is facilitating the key exchange, there is the possibility that it substitutes the client key with one it controls.

Is there any way this can be at-minimum detected by the receiving client, or better yet, actively protected against or worked around? Techniques such as the Diffie–Hellman key exchange don't seem to work here, as the channel is controlled by the entity we're trying to protect against (i.e. the server).

  • 1
    Is the server the trusted authority for validating the keys? Clients could digitally sign their public key, if the CA is not the server you are suspecting. As long as the cert chain is properly configured, the server could not interfere without being noticed.
    – schroeder
    Mar 10, 2014 at 18:09

2 Answers 2


If that could be done, CAs wouldn't exist - their sole purpose is to provide a trusted 3rd party service that you can check against from both sides and determine if something fishy happened during the key exchange.

Apart from that your only option is to have both sides do human verification by generating a hard to guess string out of the exchanged keys - same as many 'secure' mobile IMs like Silent Circle does - and have the actual users verify each other over a hard to fake channel like an eye-to-eye contact or a voice call.

With enough users in the system you can try web-of-trust kind of a thing querying other users to check if they have the same key for the same user, but that could secure you only against MITMs without sufficient power to generate a large number of valid key pairs to intercept all checks so not really all that secure.


It is possible by using certificate pinning, as long as you have control on the client certificate verification.

You must log in to answer this question.

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