title: javax.net.ssl.SSLException: Received fatal alert: bad_record_mac with Java and https
body: <p>I am getting the exception as stated in the title of the question, while connecting to server using HTTPS in Java using <code>HttpsURLConnection</code> class. Also I am trying to skip the certificate validation using <a href="https://stackoverflow.com/questions/995514/https-connection-android/1000205#1000205">the second last answer</a>. Can anyone please suggest me any way out?</p>
  
  <p><strong>Update 1: Stack trace</strong></p>
  
  <pre><code>javax.net.ssl.SSLException: Received fatal alert: bad_record_mac
      at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190)
      at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149)
      at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:133)
      at com.kuliza.sitepulse.thread.HttpConnectionThread.run(HttpConnectionThread.java:77)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>I am getting the exception for the line of code: <code>http.connect();</code> where <code>http</code> is of the type <code>HttpsURLConnection</code> class.</p>
  
  <p><strong>Update 2: SSL log</strong></p>
  
  <p>Here are the SSL Handshake logs:</p>
  
  <pre><code>[Raw read]: length = 5
  0000: 15 03 00 00 02                                     .....
  [Raw read]: length = 2
  0000: 02 14                                              ..
  Thread-6, READ: SSLv3 Alert, length = 2
  Thread-6, RECV SSLv3 ALERT:  fatal, bad_record_mac
  Thread-6, called closeSocket()
  </code></pre>
  
  <p>Any lead please, this is driving me nuts!!</p>
  
  <p>Thanks in advance!</p>