This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: SSLSocketFactory.createSocket connects using http instead of https
jQuery in Action, 3rd edition