• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Https problem when accessing through java programs

 
Anand Natraj
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am facing a problem with Https.

I have successfully configured verisign certificate and I am able to access through browser like
https://localhost:8443/hello/mypattern


But when we try to access through java program it�s throwing following exception.



javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certifica
te found
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA6275)
at sun.net.www.protocol.https.HttpsClient.afterConnect(DashoA6275)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(DashoA6275)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:617)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(DashoA6275)
at java.net.URL.openStream(URL.java:913)
at TestHttps.main(TestHttps.java:18)
Caused by: sun.security.validator.ValidatorException: No trusted certificate found
at sun.security.validator.SimpleValidator.buildTrustedChain(SimpleValidator.java:304)
at sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:107)
at sun.security.validator.Validator.validate(Validator.java:202)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(DashoA6275)
at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(DashoA6275)
... 12 more



The following is my java program.


import java.net.*;

import javax.net.*;

import java.io.*;

class TestHttps{

public static void main(String[] args){

String dataLine;

try{


System.setProperty("javax.net.ssl.keyStore","D:\\lbs2kv.keystore");
System.setProperty("javax.net.ssl.keyStorePassword","password");
URL url = new URL("https://localhost:8443/hello/mypattern");
BufferedReader htmlPage = new BufferedReader(new InputStreamReader(url.openStream()));
while ((dataLine = htmlPage.readLine()) != null){
System.out.println(dataLine);
}
htmlPage.close();

}

catch(Exception e){

// System.out.println(e.getMessage());

e.printStackTrace();

}

}

}

Pls let me know how I can solve this problem



Thanks in advance



Regards

Anand
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic