[Solved] javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair

Solve javax.net.ssl.ssl exception: java.lang.runtimeexception: could not generate DH keypair

In the process of my work, I encountered various problems. At that time, it took a long time to figure out such a summary and post it for your reference. The following views only represent my own views in the process of work. I hope you can discuss them together and find out what is missing

At that time, when I was dealing with this problem, I looked up a lot of information on the Internet, and the general solutions were three kinds:

1. Upgrade your Java version to Java 8
2. Adjust the dhparam used by HTTPS to 1024 bits
3. Modify the server to use 1024 bits dhparam

I’ve tried all three solutions

First of all, the Java 8 version is subversive. Once it is changed, the code will report errors to varying degrees. So I don’t recommend it

Secondly, the second method and the third method are relatively complicated to operate, and there are many explanations on the Internet, so I will not elaborate here. One of the reasons is that it is complicated, but the solution does not work for me. Even if it is changed, the original exception will still be reported

Therefore, after repeated access to information, went to various websites to see the relevant solutions, I finally solved this problem. Now I will summarize my solution

The key to solve this problem is to download two jar packages

bcprov-ext-jdk15on-1.52

bcprov-jdk15on-1.52

 

After downloading, you need to put these two jar packages in the

$JAVA_ HOME/jre/lib/ext

After placing it in the specified directory, you need to edit a file

The location of this file is

$JAVA_ HOME/jre/lib/security/

Modify the Java. Security file in this path
find security. Provider. 9 , and then add the following sentence:

security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider

After that, restart the application and it will run

Of course, there is another saying on the Internet, which is to add that sentence under security. Provider. 2, but it doesn’t work for me. If adding this sentence under security. Provider. 9 doesn’t work, you can also try adding this sentence under security. Provider. 2

The above is configured based on the directory of JRE, so the project needs to use JRE as follows:

Similar Posts: