AnsweredAssumed Answered

How to set up SSL/TSL to connect to server?

Question asked by John Jackson on Jul 1, 2015

Hello. I am new to this XMPP stuff and all things in general as I am just a young boy. I read up that XMPP is the #1 platform for instant messaging so I am now trying to make a small client app to see how everything works. I am most comfortable in Java so I searched for the best XMPP Library for Java and found Smack 4.1.2. However, I am having a problem connecting to a server.


My code is as follows:

public static void main(String[] args) throws SmackException, IOException, XMPPException, NoSuchAlgorithmException {
      XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();

     System.setProperty("", "keystore.jks");
     XMPPTCPConnection Connection = new XMPPTCPConnection(;
     try {
     /*    System.out.println(mConnection.isConnected());*/
     } catch (SmackException | IOException | XMPPException e) {


Now I am not sure what I am doing, I just generated a random certificate with my login credentials as my name called keystore.jks and put that in there. It sends and receives a few stanzas but then gets the following error:


12:16:29 AM SENT (0): <stream:stream xmlns='jabber:client' to='' xmlns:stream='' version='1.0' from='' xml:lang='en'>
12:16:29 AM RECV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='' id='4276879633' from='' version='1.0' xml:lang='en'>
12:16:29 AM RECV (0): <stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required/></starttls><c xmlns='' hash='sha-1' node='' ver='0vz9SwDO2HQa56GNLO1ylpEPehs='/><register xmlns=''/></stream:features>
12:16:29 AM SENT (0): <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>
12:16:29 AM RECV (0): <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
org.jivesoftware.smack.SmackException: PKIX path building failed: unable to find valid certification path to requested target
  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(
  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(
  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$



I left my login credentials in there in hopes that it may help diagnose the problem. I would greatly appreciate any help I could get. Thank you very much.