• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call URL by Java

 
amitabh pandey
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i have to call a secure url by java program and that return data in xml.
i have write java code.
but it gives

Going to connect...........
Proxy false
javax.net.ssl.SSLException: untrusted server cert chainException javax.net.ssl.SSLException: untrusted server cert chain

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(DashoA6275)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(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.AppOutputStream.write(DashoA6275)
at java.io.OutputStream.write(OutputStream.java:75)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA6275)
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect(DashoA6275)
at com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer(DashoA6275)
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.l(DashoA6275)
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.<init>(DashoA6275)
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.<init>(DashoA6275)
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a(DashoA6275)
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a(DashoA6275)
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connect(DashoA6275)
at url.main(url.java:78)

error............
i google this but i found some code who sets keystrokepassword and key all these things by system.setProperty method.
but i don't know from where i will get these values.
i am using websphere version 5 .so please tell me is there any bets way to remove this error.
Regards
Amitabh
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure this is the right forum for this, but :

when using a secure connection, you have to tell java to trust the remote server. This is done by adding that server's certificate to your keystore.
You are using java to act like a browser. Browsers have the helpful feature of having all Certificate Authority(CA)-signed certificates already loaded so that when you visit a secure site, your browser trusts it. If your browser visits a server with a self-signed certificate, you have to manually override this protection and tell your browser to trust it anyway.

"Untrusted server cert chain" means that the remote server is sending a certificate that is unknown to your java installation. You must tell java to trust this certificate just like you need to tell your browser to trust it.
This is an instruction about that:
http://cleversoft.wordpress.com/2011/02/05/how-to-add-server-certificate-to-java-keystore/

This is another one
http://www.mysamplecode.com/2011/07/avoid-javaxnetsslsslexception-untrusted.html

I haven't tried this code, so you should test it out.

Short answer is that you have to tell your java installation to trust that remote ( I assume self signed) server's certificate.
 
amitabh pandey
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim
thanks for reply.
tim i got some solution on this forum then i have implement that so
now i am getting this error

Exception java.io.IOException: HTTPS hostname wrong: should be <apollotyres.intuitbrainstorm.com>, but cert says <*.intuitbrainstorm.com>

i have update cacerts file of my java home with cacerts file from jdk .
So what this error means and how i will solve this.
Regards

Amitabh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic