• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

HttpsURLConnection - Problem in SSL Handshaking

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to make HttpsURLConnection, but I got javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found exception.

I included my code here

If u find anything wrong here, please let me know

System.setProperty("javax.net.debug","all");

System.setProperty("UseSunHttpHandler", "true");
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "my proxy ip");
System.setProperty("http.proxyPort", "80");

System.setProperty("java.protocol.handler.pkgs","javax.net.ssl");

String c_keystore = "madhu.keystore";
System.setProperty("javax.net.ssl.keyStore",c_keystore);
System.setProperty("javax.net.ssl.keyStorePassword","madhu123");
System.setProperty("javax.net.ssl.trustStore",c_keystore);
System.setProperty("javax.net.ssl.trustStorePassword","madhu123");

com.sun.net.ssl.internal.ssl.Provider.install();
java.security.Security.insertProviderAt(new com.sun.net.ssl.internal.ssl.Provider(), 1);

//URL url = new URL("https://myhostname/myfile.jsp");
URL url = new URL(null, "https://myhostname/myfile.jsp", new com.sun.net.ssl.internal.www.protocol.https.Handler());

HttpsURLConnection urlConn; //I tried with HttpURLConnection also
DataOutputStream printout;
BufferedReader input;
String content = "loginname=neonlines&password=password";

System.out.println("OPEN CONNECTION");

urlConn = (HttpsURLConnection)url.openConnection(); //I tried with HttpURLConnection also
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
urlConn.setUseCaches(false);
urlConn.setRequestMethod("POST");
urlConn.setFollowRedirects(true);


System.out.println("READ INPUT STREAM");

input = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); //EXCEPTION IN THIS LINE
String str;
String line = "";
System.out.println("PRINTING THE PAGE ");
while((str = input.readLine()) != null) {
System.out.println(str);
line += str;
}


I added the keystore "madhu.keystore" using keytool from x509 (extension cer)


I got the following exception

xecuteThread: '19' for queue: 'weblogic.kernel.Default', SEND TLSv1 ALERT: fatal, description = certificate_unknown
ExecuteThread: '19' for queue: 'weblogic.kernel.Default', WRITE: TLSv1 Alert, length = 2
ExecuteThread: '19' for queue: 'weblogic.kernel.Default', called closeSocket()
ExecuteThread: '19' for queue: 'weblogic.kernel.Default', handling exception: javax.net.ssl.SSLHandshakeException: sun.security.vali
dator.ValidatorException: No trusted certificate found
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate 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)
.
.
.
.
more

Please let me know where I 'm doing wrong.
 
Madhavan Sundarraj
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved the problem by muyself.

I dynamically installed the certificate using TrustManagerFactory and now it's working fine
 
reply
    Bookmark Topic Watch Topic
  • New Topic