How does the man in the middle attack work in Diffie–Hellman?

I think you’re confusing the basic Diffie-Hellman, which is a key exchange protocol, with the ‘authenticated version’ which uses a certificate authority (CA). Nice explanation of how the basic Diffie-Hellman is vulnerable to man-in-the-middle from RSA Labs. “The Diffie-Hellman key exchange is vulnerable to a man-in-the-middle attack. In this attack, an opponent Carol intercepts Alice’s … Read more

DH vs. DHE and ECDHE and perfect forward secrecy

It’s the ephemeral aspect of DHE and ECDHE that provides perfect forward secrecy. The idea is that even if someone records traffic and compromises the server to get its private key, they won’t be able to decipher that traffic, because they’ll be missing the ephemeral DH parameters that won’t have been saved. With fixed DH, … Read more

Why does SSL handshake give ‘Could not generate DH keypair’ exception?

The problem is the prime size. The maximum-acceptable size that Java accepts is 1024 bits. This is a known issue (see JDK-6521495). The bug report that I linked to mentions a workaround using BouncyCastle’s JCE implementation. Hopefully that should work for you. UPDATE This was reported as bug JDK-7044060 and fixed recently. Note, however, that … Read more