javax.net.ssl.SSLException: Received fatal alert: bad record mac – Simple Solution

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: 

TLS1.0

After:

SSL3.0

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);

 

Leave a Reply

Your email address will not be published. Required fields are marked *


× 8 = forty eight