SSLHandshakeException: No appropriate protocol

现象描述

系统:Centos7
OpenJDK版本:java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64

在使用微信支付或者其他https调用时报如下错误:

javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
    at sun.security.ssl.HandshakeContext.(HandshakeContext.java:171)
    at sun.security.ssl.ClientHandshakeContext.(ClientHandshakeContext.java:98)
    at sun.security.ssl.TransportContext.kickstart(TransportContext.java:220)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:428)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)

原因:JDK版本问题,参考:https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8256682

解决方案

使用奇数版本的JDK(因为奇数版本经过了所有检验,偶数版本包含未检验的内容,可能有BUG),步骤:

  1. 卸载当前安装的OpenJDK
yum remove java-1.8.0-openjdk*
  1. 查找可安装的版本
[root@test001 ~]# yum --showduplicate list java* | grep 1.8.0
java-1.8.0-openjdk.x86_64                   1:1.8.0.275.b01-0.el7_9     @updates
java-1.8.0-openjdk-headless.x86_64          1:1.8.0.275.b01-0.el7_9     @updates
java-1.8.0-openjdk.i686                     1:1.8.0.262.b10-1.el7       base
java-1.8.0-openjdk.x86_64                   1:1.8.0.262.b10-1.el7       base
java-1.8.0-openjdk.i686                     1:1.8.0.272.b10-1.el7_9     updates
java-1.8.0-openjdk.x86_64                   1:1.8.0.272.b10-1.el7_9     updates
java-1.8.0-openjdk.i686                     1:1.8.0.275.b01-0.el7_9     updates
java-1.8.0-openjdk.x86_64                   1:1.8.0.275.b01-0.el7_9     updates
java-1.8.0-openjdk.i686                     1:1.8.0.282.b08-1.el7_9     updates
java-1.8.0-openjdk.x86_64                   1:1.8.0.282.b08-1.el7_9     updates
java-1.8.0-openjdk.i686                     1:1.8.0.292.b10-1.el7_9     updates
java-1.8.0-openjdk.x86_64                   1:1.8.0.292.b10-1.el7_9     updates
...

  1. 安装1.8.0.275版本
yum install java-1.8.0-openjdk-1.8.0.275.b01-0.el7_9.x86_64

你可能感兴趣的:(SSLHandshakeException: No appropriate protocol)