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這個目錄下, 然後重啓程序就好了.
.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章