I\'m getting a javax.net.ssl.SSLException: Received fatal alert: bad_record_mac
for an HTTPS connection. This doesn\'t happen for every request -- if I send th
Try set com.sun.net.ssl.rsaPreMasterSecretFix
to true
.
It is a hard to say what causing this. You need to find out by analyzing the logs, set the
System.setProperty("javax.net.debug", "all");
and check what is wrong.
A problem may be that server is not supporting TLS, which may be picked by implementation. To make sure that you always use the plain SSLv3 by setting the property:
System.setProperty("https.protocols", "SSLv3");
Another cause may be the poor network, causing that occasionally some packets are broken but still have the correct checksum. In that case you may only retry the request.
According to this rubygems issue and the detailed description of the error (see below), it appears to be a bug in Oracle's JDK that is not present in OpenJDK. I recall (but cannot verify) that there was a bug in OpenSSL that also caused this error, so you may want to check the software on the other side of the connection.
You can read more details about what this error means here.