This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes going mad about HttpsURLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "going mad about HttpsURLConnection" Watch "going mad about HttpsURLConnection" New topic

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,
System.setProperty("", "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());
String response = in.readLine();
Torsten Schippel
Ranch Hand

Joined: May 09, 2003
Posts: 62
with HttpsURLConnection:
System.setProperty("", "123456");
URL url = new URL("");
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 -
Consider Paul's rocket mass heater.
subject: going mad about HttpsURLConnection
Similar Threads
HTTPS Request with Proxy server.
xml-document into mySQL database ?
Connecting via a specific Socket?
Sms Sending From Pc to mobile
Connecting a VB web browser with a Java Server