wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes Call URL by Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Call URL by Java" Watch "Call URL by Java" New topic

Call URL by Java

amitabh pandey

Joined: Mar 16, 2012
Posts: 9
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)

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.
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

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:

This is another one

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

Joined: Mar 16, 2012
Posts: 9
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.

I agree. Here's the link: http://aspose.com/file-tools
subject: Call URL by Java
Similar Threads
Untrusted server cert chain ?
javax.net.ssl.SSLException: untrusted server cert chain
javax.net.ssl.SSLException: untrusted server cert chain