javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorExcept

Friends,

I try to connect a secured https web application deployed in Tomcat server . I am using a standalone java application using the org.apache.commons.httpclient. to connect the above web-application .

However i get the following error ...

Any suggestion in this matter would be highly appreciated ....

/********************************Error ***************************************/

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

at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1518)

at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)

at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:848)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)

at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)

at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:818)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1030)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:622)

at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)

at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)

at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)

at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:827)

at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1975)

at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)

at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)

at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)

at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)

at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)

at SecureTest_ARPS.main(SecureTest_ARPS.java:51)

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)

at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)

at sun.security.validator.Validator.validate(Validator.java:203)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172)

at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:841)

... 17 more

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:236)

at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:194)

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:216)

... 22 more

/********************************Error ***************************************/

[3830 byte] By [dynamicdhiraja] at [2007-11-27 10:23:57]
# 1

Would like to add a small snapshot of my Java code here .

try

{

Protocol myhttps = new Protocol(TRANSPORT_PROTOCOL, new AuthSSLProtocolSocketFactory(new URL(KEYSTORE_URL), KEYSTORE_PW, null,null), SERVER_PORT);

//Registers the protocol with a given identifier

Protocol.registerProtocol("myhttps",new Protocol(TRANSPORT_PROTOCOL, new AuthSSLProtocolSocketFactory(new URL(KEYSTORE_URL), KEYSTORE_PW, null, null), SERVER_PORT));

// Handles theclient side of the HTTP protocol .

httpClient = new HttpClient();

//Sets the Host,Port annd the Protocol.

httpClient.getHostConfiguration().setHost(HOST_URL, SERVER_PORT, myhttps);

//Sets whether authentication should be attempted preemptively.

Credentials defaultcreds = new UsernamePasswordCredentials(SERVER_REALM_USERNAME, SERVER_REALM_PW);

httpClient.getState().setCredentials(new AuthScope(SERVER_HOST, M2FAServerPort,SERVER_REALM), defaultcreds);

httpPost = new PostMethod(HOST_URL);

httpClient.executeMethod(httpPost);

}

catch(Exception ex ){

ex.printStackTrace();

}

dynamicdhiraja at 2007-7-28 17:24:51 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2

Friends ,

Can anybody please guide me as to what is the source of the error or why is it being thrown ?

regards,

Dhiraj

dynamicdhiraja at 2007-7-28 17:24:51 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 3

I have the same problem.

+1

anton_ananicha at 2007-7-28 17:24:51 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...