Recently, I encountered a Java exception called bad_record_mac while running a Java software that uses jsoup connection.
After 1 hour of trial and error, I realized the website I am connecting allows only SSL 3.0 which previously is not.
Before:
After:
To Solve This:
I added one properties line.
System.setProperty("https.protocols", "SSLv3,SSLv2Hello");
And now jsoup connection is able to connect properly using the correct HTTPS protocol. Note, don’t forget to include your SSL certificate as well when making connection.
System.setProperty("javax.net.ssl.trustStore", certPath);
What would be the value of certPath? I assume this is a directory location ?
Yeap. It is the absolute path to the Java Key Store (.JKS) file.
For example in Linux “/home/users/mycert/mycertificate.jks”. Includes the file name as well.
Here’s how to import .cer certificate into .jks file – http://stackoverflow.com/questions/4325263/how-to-import-a-cer-certificate-into-a-java-keystore
Nice