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