在Java8及高版本以上的版本在调用ssl时会出现javax.net.ssl.SSLHandshakeException: No appropriate protocol的异常。
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) at sun.security.ssl.HandshakeContext.(HandshakeContext.java:171) ~[na:1.8.0_292] at sun.security.ssl.ClientHandshakeContext. (ClientHandshakeContext.java:98) ~[na:1.8.0_292] at sun.security.ssl.TransportContext.kickstart(TransportContext.java:220) ~[na:1.8.0_292] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:428) ~[na:1.8.0_292] at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:316) ~[mysql-connector-java-8.0.17.jar:8.0.17] at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188) ~[mysql-connector-java-8.0.17.jar:8.0.17] at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99) ~[mysql-connector-java-8.0.17.jar:8.0.17] at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:331) ~[mysql-connector-java-8.0.17.jar:8.0.17] ... 68 common frames omitted
解决办法如下:
修改jre/lib/security/java.security中的disabledAlgorithms,删除SSLv3, TLSv1, TLSv1.1,然后重启应用即可。
jdk.tls.disabledAlgorithms=RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, include jdk.disabled.namedCurves
参考链接:Java调用ssl出现异常:javax.net.ssl.SSLHandshakeException: No appropriate protocol_嘉禾笔记-CSDN博客
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)