我有2個應用程序安裝在2個不同的服務器上(1)託管在Glassfish(2)一個批處理服務器(獨立的Java應用程序)。 這兩個應用程序都使用一個通用的Java程序(以jar文件的形式)來調用外部服務器。我正在使用'CloseableHttpClient'來連接到該外部第三方服務器。 從我的服務器一(GlassFish的),我能夠調用,並從外部服務器,但批量服務器上相同的程序響應拋出下面SSL exceptoion證書存在於cacert文件中,但引發ssl異常
javax.net.ssl.SSLHandshakeException:sun.security.validator .ValidatorException:PKIX路徑構建失敗:sun.security.provider.certpath.SunCertPathBuilderException:無法找到有效的證書路徑,請求目標 at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174 ) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1747) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241) 在com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(H andshaker.java:235) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1209) at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker。 java:135) at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593) at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java: 529) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:943) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1215) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1199) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:290) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:259) at org.apache。 http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:125) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:319) at org.apache.http.impl.execchain。 MainClientExec.establishRoute(MainClientExec.java:363) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec。 java:195) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108) 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:106) at com.csid.sms.util.postup。 PostUpRestClient.executeRequest(PostUpRestClient.java:169) at com.csid.sms.util.postup.PostUpRestClient.executeJsonPost(PostUpRestClient.java:134) at com.csid.sms.util.postup.PostUpRestClient.executeJsonRequest(PostUpRestClient。 java:106) at com.csid.sms.util.postup.PostUpEmailRoute.triggerMessage(PostUpEmailRoute.java:213) at itm.mo nitor.SummaryEmailPostupRoute.triggerMessage(SummaryEmailPostupRoute.java:154) 在com.csid.sms.messaging.MessagingHandler.triggerMessage(MessagingHandler.java:60) 在itm.monitor.SummaryEmailRoute.sendEmail(SummaryEmailRoute.java:49) 在itm.monitor.BatchEmailProcessor.sendEmail(BatchEmailProcessor.java:105) at it.monitor.BatchEmailProcessor.call(BatchEmailProcessor。java:51) at java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask。運行(FutureTask.java:138) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:439) at java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) 在java.util.concurrent.ThreadPoolExecutor中的$ Worker.runTask(ThreadPoolExecutor.java:895) 在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run( ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662) 引起者:sun.security.validator.ValidatorExce ption:PKIX路徑構建失敗:sun.security.provider.certpath.SunCertPathBuilderException:找不到有效的證書路徑,請求sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:323) at sun.security要求的目標 。 validator.PKIXValidator.engineValidate(PKIXValidator.java:217) at sun.security.validator.Validator.validate(Validator.java:218) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl。 java:126) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java: 249) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1188)(SunCertPathBuilder.java:174) 在java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238) 在sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:318) ...... 43多個
注意 - 這異常是從批處理服務器而不是從管理服務器拋出(託管在glassfish中)。
谷歌搜索後發現此錯誤發現外部服務器獲取的證書可能不會由某些受信任的機構頒發,因此我通過使用'installCert'(this java program)導入了證書。
現在使用keytool命令
的keytool -list -keystore cacerts的
,我可以看到,外部證書,在受信任的證書列表中列出覈實證書中CACERT。 但仍然超過SSL異常。
任何想法傢伙? 爲什麼我沒有從管理服務器(glassfish)獲得任何類型的SSL期望,這也是使用相同的Java代碼? glassfish是否像瀏覽器一樣自動導入證書?
這兩個都是使用不同的JRE,我檢查批處理服務器JRE和證書在那裏。 – vermap