Linux下本地java服务连接websocket问题( PKIX path building failed: ... path to requested target)

jar包跑着一个数据推送服务,连接远端wss://app.test.com:12345进行数据推送,突然数据就不推送更新了
重启对应的服务,启动失败,前台运行java -jar userpush.jar
主要 报错如下:
javax.websocket.DeploymentException: The HTTP request to initiate the WebSocket connection failed
...
Caused by: java.util.concurrent.ExecutionException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
...
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
...
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
...
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
问题解决
下载如下的java文件:
 
编译:
# 与jar包运行的java环境保持一致,直接在对应服务器上编译
javac InstallCert.java

安装目标服务器的证书:

java InstallCert  app.test.com:443

# 执行完这个命令以后会在当前目录生成一个名为jssecacerts的文件, 复制到$JAVA_HOME/jre/lib/security这个目录下, 然后重启程序就好了.
.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章