0
votes

I am trying to configure SSL with Tomcat 7 in eclipse for java.I have configured 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"/>

I am doing a application client/server, the server works good but when I execute the client I have the following error:

Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: jav ax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKI X path building failed: sun.security.provider.certpath.SunCertPathBuilderExcepti on: unable to find valid certification path to requested target at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle (URLConnectionClientHandler.java:155) at com.sun.jersey.api.client.Client.handle(Client.java:652) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) at clientWAN.client.main(client.java:109) Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.Validator Exception: PKIX path building failed: sun.security.provider.certpath.SunCertPath BuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alerts.getSSLException(Unknown Source) at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source) at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source) at sun.security.ssl.Handshaker.processLoop(Unknown Source) at sun.security.ssl.Handshaker.process_record(Unknown Source) at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source ) at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect (Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown S ource) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unk nown Source) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler$1$1.ge tOutputStream(URLConnectionClientHandler.java:238) at 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) at sun.nio.cs.StreamEncoder.flush(Unknown Source) at java.io.OutputStreamWriter.flush(Unknown Source) at java.io.BufferedWriter.flush(Unknown Source) at com.sun.jersey.core.util.ReaderWriter.writeToAsString(ReaderWriter.ja va:191) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writ eToAsString(AbstractMessageReaderWriterProvider.java:128) at com.sun.jersey.core.impl.provider.entity.BaseFormProvider.writeTo(Bas eFormProvider.java:109) at com.sun.jersey.core.impl.provider.entity.FormProvider.writeTo(FormPro vider.java:88) at 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) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invok e(URLConnectionClientHandler.java:217) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle (URLConnectionClientHandler.java:153) ... 5 more Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find vali d certification path to requested target at sun.security.validator.PKIXValidator.doBuild(Unknown Source) 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 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Sourc e) at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source) at java.security.cert.CertPathBuilder.build(Unknown Source) ... 41 more

I don't know the cause for this problem.I have seen several similar problems in this web, but I have been unable to solve. I need to help. Thanks very much.

1

1 Answers

0
votes

Your client doesn't trust the server certificate. Get it signed, or export it into the client's truststore.