AnsweredAssumed Answered

Connect to OF with Smack 4.1.8 via SSL (Port 5223)

Question asked by Sebastian on Aug 26, 2016
Latest reply on Aug 27, 2016 by Flow

Hi everybody,

 

I have a little problem: I want to connect to my Openfire server with Smack 4.1.8 via SSL (Port: 5223). I use the folowing code:


config = XMPPTCPConnectionConfiguration.builder()

 

     .setServiceName(SERVICENAME)

     .setHost("127.0.0.1")

     .setPort(5223)

     .setCompressionEnabled(true)

      .setDebuggerEnabled(true)

      .setSocketFactory(SSLSocketFactory.getDefault())

      .setUsernameAndPassword(USERNAME, PASSWORD)

      .setSecurityMode(SecurityMode.required)

      .build();

connection = new XMPPTCPConnection(config);

connection.setPacketReplyTimeout(3000);

 

connection.connect();

connection.login();

 

But everytime I get a timeout.

On the server side it tells me: SSL Handshake failed.

 
  And if I use the DummySSLFactory, i get:

java.net.SocketException: Unconnected sockets not implemented

at javax.net.SocketFactory.createSocket(SocketFactory.java:125)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:573)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:851)

at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:364)

at de.smacktest.sender.ID_RegistrationClient.login(ID_RegistrationClient.java:62)

at de.smacktest.sender.ID_RegistrationClient.<init>(ID_RegistrationClient.java:41)

at de.smacktest.App.main(App.java:15)

Caused by: java.lang.UnsupportedOperationException

at javax.net.SocketFactory.createSocket(SocketFactory.java:123)

... 6 more


  Sorry, I am quite new to SSL. Do I need a certificate? How to create or import a certificate?


  If anyone could help me out, it would be great


  Thank you

Outcomes