欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JDK异常处理No appropriate protocol

程序员文章站 2022-03-04 13:09:09
...

异常展示

javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
        at sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:171) ~[na:1.8.0_292]
        at sun.security.ssl.ClientHandshakeContext.<init>(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 org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275) ~[httpclient-4.3.2.jar:4.3.2]
        at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:254) ~[httpclient-4.3.2.jar:4.3.2]
        at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:118) ~[httpclient-4.3.2.jar:4.3.2]
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:314) ~[httpclient-4.3.2.jar:4.3.2]
        at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363) ~[httpclient-4.3.2.jar:4.3.2]
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219) ~[httpclient-4.3.2.jar:4.3.2]
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195) ~[httpclient-4.3.2.jar:4.3.2]
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:85) ~[httpclient-4.3.2.jar:4.3.2]
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108) ~[httpclient-4.3.2.jar:4.3.2]

分析: 倘若是2021年5月后安装的jdk,最新版jdk不支持ssl
解决办法

找到jdk 1.8安装目录,找到C:\Program Files\Java\jre里面的lib\security 下面有个java.security。找到对应的SSLv3,删除掉,重启项目就好了。(删掉SSLv3就是允许SSL调用)

JDK异常处理No appropriate protocol
红框中的全部删除掉即可通过SSL调用

处理JDK相关的linux命令

查询系统自带的jdk包括自己安装的openjdk

rpm -qa | grep java

删除自带的jdk或者自己安装的openjdk

rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64

命令介绍:
rpm     管理套件  
-e     删除指定的套件
--nodeps  不验证套件档的相互关联性

JDK相关版本下载

JDK最新SSL访问阻断版本地址

JDK历史版本下载地址

安装

1.将安装包上传到服务器例如 /opt/java 文件夹下
2.解压
3.配置环境文件

export JAVA_HOME=/opt/java/jdk1.8.0_201
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:{JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

4.使环境文件生效

source /etc/profile
相关标签: java