AnsweredAssumed Answered

SSL/TLS on Port 5222

Question asked by Colin Lin on Nov 8, 2014
Latest reply on Mar 3, 2015 by Flow

Hi:

 

I have my Openfire up and running with a properly signed certificate for my keystore (/opt/openfire/resource/security/keystore). Under Server Settings -> Security Settings, I have the Client Connection Security set to Required, and then tried to connect to my Openfire server via below code:

 

try {

  ConnectionConfiguration conf = new ConnectionConfiguration("abc.foo.com", 5222);

            conf.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);

            conf.setSocketFactory(new DummySSLSocketFactory());

            conf.setReconnectionAllowed(true);

            conf.setRosterLoadedAtLogin(true);

            conf.setSendPresence(false);

           

            XMPPConnection con = new XMPPTCPConnection(conf);

      

  con.connect();

  con.login("user1@abc.foo.com", "123456");

  } catch (Exception e) {

  e.printStackTrace();

  }

 

I received below error:

 

org.jivesoftware.smack.SmackException$NoResponseException

  at org.jivesoftware.smack.XMPPConnection.throwConnectionExceptionOrNoResponse(XMPP Connection.java:548)

  at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwConnectionExceptionOrNoRespon se(XMPPTCPConnection.java:867)

  at org.jivesoftware.smack.tcp.PacketReader.startup(PacketReader.java:113)

  at org.jivesoftware.smack.tcp.XMPPTCPConnection.initConnection(XMPPTCPConnection.j ava:482)

  at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC onnection.java:440)

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

  at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:396)

  at MainApp.main(MainApp.java:38)

Nov 08, 2014 7:45:23 PM org.jivesoftware.smack.XMPPConnection callConnectionClosedOnErrorListener

WARNING: Connection closed with error

javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

  at sun.security.ssl.SSLSocketImpl.checkEOF(Unknown Source)

  at sun.security.ssl.AppInputStream.read(Unknown Source)

  at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)

  at sun.nio.cs.StreamDecoder.implRead(Unknown Source)

  at sun.nio.cs.StreamDecoder.read(Unknown Source)

  at java.io.InputStreamReader.read(Unknown Source)

  at java.io.BufferedReader.read1(Unknown Source)

  at java.io.BufferedReader.read(Unknown Source)

  at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2992)

  at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)

  at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1410)

  at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)

  at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)

  at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:279)

  at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:47)

  at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:81)

Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

  at sun.security.ssl.InputRecord.handleUnknownRecord(Unknown Source)

  at sun.security.ssl.InputRecord.read(Unknown Source)

  at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)

  at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)

  at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)

  at sun.security.ssl.AppOutputStream.write(Unknown Source)

  at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)

  at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)

  at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)

  at sun.nio.cs.StreamEncoder.flush(Unknown Source)

  at java.io.OutputStreamWriter.flush(Unknown Source)

  at java.io.BufferedWriter.flush(Unknown Source)

  at org.jivesoftware.smack.tcp.PacketWriter.openStream(PacketWriter.java:235)

  at org.jivesoftware.smack.tcp.PacketWriter.writePackets(PacketWriter.java:158)

  at org.jivesoftware.smack.tcp.PacketWriter.access$000(PacketWriter.java:40)

  at org.jivesoftware.smack.tcp.PacketWriter$1.run(PacketWriter.java:77)

 

 

However, when I change the port from 5222 to 5223, it worked fine. Is there anything else I need to do to make the SSL/TLS working on port 5222?

Outcomes