| Author |
going mad about HttpsURLConnection
|
Thomas Rochon
Ranch Hand
Joined: Jul 11, 2002
Posts: 72
|
|
Hi there , maybe there are thousands of similar postings in that forum, or maybe there are millions of great tutorials about it on the internet. As far as it concerns me, I found loads of very abstract papers about that ssl stuff, but much to abstruse for a newb like me. So here's my problem: There's a https server I want to connect to with my Java application. All I have is the server's IP, port, a keystore with client trusted certificates and a password. That's it. I'm sure, there has to be a way to connect to that stupid server, but since now I didn't find a way. Would you please be so kind to help me out of that problem? I'm really loosing hope Thanx in advance ... - Thomas - [ September 25, 2003: Message edited by: Thomas Rochon ]
|
 |
Torsten Schippel
Ranch Hand
Joined: May 09, 2003
Posts: 62
|
|
Hi Thomas, try: System.setProperty("javax.net.ssl.trustStore","mykeystore"); System.setProperty("javax.net.ssl.trustStorePassword", "123456"); SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); SSLSocket client = (SSLSocket) factory.createSocket(host, port); DataInput in = new DataInputStream(client.getInputStream()); PrintStream out = new PrintStream(client.getOutputStream()); out.println("ClientMessage"); String response = in.readLine(); System.out.println(response); client.close(); HTH Torsten
|
 |
Torsten Schippel
Ranch Hand
Joined: May 09, 2003
Posts: 62
|
|
Sorry, with HttpsURLConnection: System.setProperty("javax.net.ssl.trustStore","mykeystore"); System.setProperty("javax.net.ssl.trustStorePassword", "123456"); URL url = new URL("https://127.0.0.1:443/"); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
 |
Thomas Rochon
Ranch Hand
Joined: Jul 11, 2002
Posts: 72
|
|
Hi Torsten ! Cant believe it's that simple. But it works ! Your small code snippet helped me out of a lot of trouble. Thanx ! Thanx a lot ! Best regards, - Thomas -
|
 |
 |
|
|
subject: going mad about HttpsURLConnection
|
|
|