[英]Intermittent - SunCertPathBuilderException: unable to find valid certification path to requested target
[英]Resolving: SunCertPathBuilderException: unable to find valid certification path to requested target
我的異常的完整跟蹤是:
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
首先,我想說的是,我知道這是一個非常普遍的例外,因此我嘗試應用不同的解決方案,稍后將對其進行描述,但是沒有任何幫助。
所以,我在同一台機器上有兩個tomcat 7實例。 直接來說,這些實例具有各自的CATALINA_BASE
目錄,但具有共同的CATALINA_HOME
。 它們也是隔離的-配置了端口,這樣實例就不會受到干擾。 一個實例-服務器-具有已部署的Web應用程序servlet。 客戶端的另一個實例-servlet。
這是服務器tomcat的server.xml的片段:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="true" sslProtocol="TLS"
truststoreFile="C:/Users/dpivovar/ssl_server.jks"
truststorePass="start123"
keystoreFile="C:/Users/dpivovar/ssl_server.jks"
keystorePass="start123"/>
客戶端tomcat的這個片段:
<Connector port="8444" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
truststoreFile="C:/Program Files/Java/jdk1.7.0_45/jre/lib/security/cacerts"
truststorePass="changeit"
keystoreFile="C:/Users/dpivovar/ssl_client.jks"
keystorePass="start123" />
工作流程:客戶端嘗試對服務器執行GET,但是它獲得了上述異常。
證書呢? 我使用了Java keytool。 我one keystore for server and separate for client
了one keystore for server and separate for client
了one keystore for server and separate for client
。 每個密鑰庫都包含對應方的private key
和public certificate
。 在上面的示例中,客戶端信任庫引用了jre cacerts密鑰庫,因為我發現的解決方案之一是將服務器的公共證書放入jre cacerts。 但這對我不起作用。 我發現的另一種解決方案( http://www.nodsw.com/blog/leeland/2006/12/06-no-more-unable-find-valid-certification-path-requested-target )通過InstallCert工具提供了一個解決方案服務器的公共證書,然后在客戶端信任庫中使用它。 因此,現在,在jre caserts中有服務器的公共證書,但引發了異常。 另外,我有一個簡單的客戶端示例-它是普通的Java程序,通過系統屬性,我設置了用於客戶端的密鑰庫的必需路徑,並以相同的方式使GET到服務器,並且它可以正常工作,發生握手,建立連接。
那么,您能幫我嗎,可能是什么問題呢?是什么阻止了部署在tomcat上的客戶端與服務器建立ssl連接?
truststoreFile="C:/Users/dpivovar/ssl_server.jks"
truststorePass="start123"
這些屬性不存在。 您必須通過系統屬性進行設置。
我通過在tomcat配置系統中為keystore / truststore和keystorePassword / truststorePassword設置Java屬性來解決此問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.