Tomcat 7和SSL配置问题

时间:2015-03-24 10:06:53

标签: web-services security tomcat ssl https

我正在尝试使用eclipse中的Tomcat 7为java配置SSL。我已经配置了server.xml:

<Connector SSLEnabled="true" clientAuth="false" keystoreFile="/.keystore" keystorePass="mypass" maxThreads="150" port="8443" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS"/>

我正在做一个应用程序客户端/服务器,服务器运行良好但是当我执行客户端时出现以下错误:

  
    

线程中的异常&#34; main&#34; com.sun.jersey.api.client.ClientHandlerException:jav     ax.net.ssl.SSLHandshakeException:     sun.security.validator.ValidatorException:PKI X路径构建失败:     sun.security.provider.certpath.SunCertPathBuilderExcepti on:无法     找到所请求目标的有效证书路径             在com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle     (URLConnectionClientHandler.java:155)             在com.sun.jersey.api.client.Client.handle(Client.java:652)             在com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)             在com.sun.jersey.api.client.WebResource.access $ 200(WebResource.java:74)             在com.sun.jersey.api.client.WebResource $ Builder.post(WebResource.java:570)             at clientWAN.client.main(client.java:109)引起:javax.net.ssl.SSLHandshakeException:sun.security.validator.Validator     例外:PKIX路径构建失败:     sun.security.provider.certpath.SunCertPath BuilderException:无法     找到所请求目标的有效证书路径             在sun.security.ssl.Alerts.getSSLException(未知来源)             at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)             在sun.security.ssl.Handshaker.fatalSE(未知来源)             在sun.security.ssl.Handshaker.fatalSE(未知来源)             at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)             在sun.security.ssl.ClientHandshaker.processMessage(未知来源)             在sun.security.ssl.Handshaker.processLoop(未知来源)             在sun.security.ssl.Handshaker.process_record(未知来源)             at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)             在sun.security.ssl.SSLSocketImpl.performInitialHandshake(未知来源     )             在sun.security.ssl.SSLSocketImpl.startHandshake(未知来源)             在sun.security.ssl.SSLSocketImpl.startHandshake(未知来源)             在sun.net.www.protocol.https.HttpsClient.afterConnect(未知来源)             在sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect     (未知来源)             at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(未知     资源)             at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown S     乌尔斯河)             在sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unk)     nown来源)             at com.sun.jersey.client.urlconnection.URLConnectionClientHandler $ 1 $ 1.ge     tOutputStream(URLConnectionClientHandler.java:238)             在com.sun.jersey.api.client.CommittingOutputStream.commitStream(Committ     ingOutputStream.java:117)             at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutp     utStream.java:89)             at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)             at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)             at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)             在sun.nio.cs.StreamEncoder.flush(未知来源)             在java.io.OutputStreamWriter.flush(未知来源)             在java.io.BufferedWriter.flush(未知来源)             at com.sun.jersey.core.util.ReaderWriter.writeToAsString(ReaderWriter.ja)     VA:191)             在com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writ     eToAsString(AbstractMessageReaderWriterProvider.java:128)             在com.sun.jersey.core.impl.provider.entity.BaseFormProvider.writeTo(Bas     eFormProvider.java:109)             在com.sun.jersey.core.impl.provider.entity.FormProvider.writeTo(FormPro     vider.java:88)             在com.sun.jersey.core.impl.provider.entity.FormProvider.writeTo(FormPro     vider.java:58)             at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWri)     ter.java:300)             在com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invok     E(URLConnectionClientHandler.java:217)             在com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle     (URLConnectionClientHandler.java:153)             ... 5更多引起:sun.security.validator.ValidatorException:PKIX路径构建失败:     sun.security.provider.certpath.SunCertPathBuilderException:无法     找到要求目标的vali d认证路径             在sun.security.validator.PKIXValidator.doBuild(未知来源)             at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)             at sun.security.validator.Validator.validate(Unknown Source)             at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)             at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)             at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Sour)     CE)             ... 35更多引起:sun.security.provider.certpath.SunCertPathBuilderException:无法     找到所请求目标的有效证书路径             在sun.security.provider.certpath.SunCertPathBuilder.build(未知的Sourc     E)             在sun.security.provider.certpath.SunCertPathBuilder.engineBuild(未知     资源)             在java.security.cert.CertPathBuilder.build(未知来源)             ......还有41个

  

我不知道这个问题的原因。我在这个网站上看到过几个类似的问题,但我一直无法解决。我需要帮忙。 非常感谢。

1 个答案:

答案 0 :(得分:0)

您的客户端不信任服务器证书。将其签名,或将其导出到客户端的信任库。