File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes SSLSocketFactory.createSocket connects using http instead of https Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "SSLSocketFactory.createSocket connects using http instead of https" Watch "SSLSocketFactory.createSocket connects using http instead of https" New topic

SSLSocketFactory.createSocket connects using http instead of https

Anders Nilsson

Joined: Mar 22, 2013
Posts: 1
I need to make a handshake. I do it with the code below.

I'm running the code in an applet and it works fine when running directly against the server. The problem I have occurs when the same code runs via a proxy.
I'm looking in the java console with trace level 5 activated. Directly after the code line "SSLSocket socket = (SSLSocket) factory.createSocket("", 443);" is executed
this line appears in the java console "network: Connecting with proxy=DIRECT". After this the applet stops working. I think it is because the
proxy will not allow http traffic on port 443.

Can anyone tell me why it is connecting using http and what I should do to make it connect using https?


public class Handshake

class MyHandshakeListener implements HandshakeCompletedListener

public void handshakeCompleted(HandshakeCompletedEvent e)
System.out.println("Handshake succesful!");
System.out.println("Using cipher suite: " + e.getCipherSuite());

public void DoHandshake()
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket("", 443);
String[] suites = socket.getSupportedCipherSuites();
socket.addHandshakeCompletedListener(new MyHandshakeListener());
catch (Exception e)

I agree. Here's the link:
subject: SSLSocketFactory.createSocket connects using http instead of https
It's not a secret anymore!