Why Does SSL Handshake Give "Could Not Generate DH Keypair" Exception?
When attempting an SSL connection with specific IRC servers, such as aperture.esper.net:6697, an exception occurs: "Could not generate DH keypair."
This exception stems from the preferred encryption method of the server, which uses a large prime size for Diffie-Hellman (DH) key exchange. By default, Java accepts DH key sizes up to 1024 bits, but the server in question uses a larger prime size, causing the exception.
Root Cause:
The root cause of the issue is the mismatch between the Java SSL implementation's maximum acceptable DH key size (1024 bits) and the server's preferred larger prime size.
Workaround:
To resolve this issue, you can use one of the following workarounds:
Note: If the server's DH key size is larger than 2048 bits, you will still need to use the BouncyCastle workaround or wait for Java 8's JDK-8072452 fix to be released.
The above is the detailed content of Why Does My Java SSL Handshake Fail with a 'Could Not Generate DH Keypair' Error?. For more information, please follow other related articles on the PHP Chinese website!