简体   繁体   中英

how to handle exception “javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure” in java7

I am posting this question after trying many options. Below are the options I tried. 1. Add property into {JAVA_HOME}/jre/lib/security/java.security security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider

download jar from below link and add to {JAVA_HOME}/jre/lib/security http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html

2.Adding java -Dhttps.protocols=TLSv1.2,TLSv1.1,TLSv1

3.Adding System.setProperty("https.protocols", "TLSv1.2,TLSv1.1,SSLv3"); before connect.

Still I am getting this issue, any help very much appreciated in advance.

14:37:28,040 INFO  [STDOUT] SALM:login#TID:224#ST:2019-07-12 14:35:03.614, WRITE: TLSv1.2 Handshake, length = 227

14:37:28,311 INFO  [STDOUT] SALM:login#TID:224#ST:2019-07-12 14:35:03.614, READ: TLSv1.2 Alert, length = 2

14:37:28,314 INFO  [STDOUT] SALM:login#TID:224#ST:2019-07-12 14:35:03.614, RECV TLSv1 ALERT:  fatal, handshake_failure

14:37:28,317 INFO  [STDOUT] SALM:login#TID:224#ST:2019-07-12 14:35:03.614, called closeSocket()

14:37:28,319 INFO  [STDOUT] SALM:login#TID:224#ST:2019-07-12 14:35:03.614, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

14:37:32,023 FATAL [com.de.teamdynamics.webhelper.TeamDynamicHelper] CurrentThreadID=224 TeamDynamicHelper:processTeamDynamicsDataJob:Error - javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
14:37:32,024 FATAL [com.de.base.util.general.WebUtil] CurrentThreadID=224 Exception===> Values ===>javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
    at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1979)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1086)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1092)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
    at com.de.teamdynamics.webhelper.TeamDynamicHelper.pushTeamDynamicsData(TeamDynamicHelper.java:1039)

This is what worked for me finally:

SSLContext context = SSLContext.getInstance("TLSv1.2");
context.init(null,null,null);
SSLContext.setDefault(context);

我多次遇到此问题,对我来说它是通过更新US_export_policy.jar并在$JAVA_HOME/jre/lib/security/cacerts添加ssl证书来工作的,您可以参考以下链接: https : //drissamri.be/blog/2017 / 02/22 / trusting-lets-encrypt-java /

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM