javax.net.ssl.SSLException:收到致命警报:Java 和 https 的 bad_record_mac
在使用 Java 中的 HTTPS 使用 HttpsURLConnection 类连接到服务器时,我收到了问题标题中所述的异常。另外,我尝试使用倒数第二个答案跳过证书验证。接下来我可以尝试什么?
更新 1:堆栈跟踪
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)
我收到代码行的异常: http.connect();
其中 http
的类型为 <代码>HttpsURLConnection 类。
更新 2:SSL 日志
以下是 SSL 握手日志:
[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()
I am getting the exception as stated in the title of the question, while connecting to server using HTTPS in Java using HttpsURLConnection
class. Also I am trying to skip the certificate validation using the second last answer. What can I try next?
Update 1: Stack trace
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)
I am getting the exception for the line of code: http.connect();
where http
is of the type HttpsURLConnection
class.
Update 2: SSL log
Here are the SSL Handshake logs:
[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()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这来得太晚了,但它可能会对某人有所帮助,对吧?
如果您包含更多导致您包含的错误的 ssl 连接的调试输出,可能会有所帮助。我看到了同样的错误,只是通过包含 -Dhttps.protocols=SSLv3 解决了它
-Dforce.http.jre.executor=true 在我的虚拟机争论中......所以如果你幸运的话,这可能也适合你。
这是我的踪迹:
I know this is coming in way late, but it might help someone, right?
It might help if you include more of the debug output for the ssl connection leading up to the error which you included. I was seeing the same error and just solved it by including -Dhttps.protocols=SSLv3
-Dforce.http.jre.executor=true in my VM arguements ... so if you're lucky, that might work for you too.
Here's my trace: