0

I am using smack libary to connect ejabberd xmpp server, I have hosted ejabberd in my locally . And it works fine, I can connect, send text message . The code I used to connect is following

    public static final String HOST = "remote_host_ip_address";
    public static final int PORT = 5222;
    public static final int CONNECT_TIME_OUT = 20000;
    public static final String RESOURCE = "Smack";
      XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
        configBuilder.setHost(HOST);
        configBuilder.setPort(PORT);
        //configBuilder.setServiceName("localhost");
        configBuilder.setServiceName("hostname.com");

        configBuilder.setResource(RESOURCE);
        configBuilder.setCompressionEnabled(true);
        configBuilder.setConnectTimeout(CONNECT_TIME_OUT);
        //configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
        connectionConfig = configBuilder.build();
        connection = new XMPPTCPConnection(connectionConfig);
        accountManager = AccountManager.getInstance(connection);
        chatManager = ChatManager.getInstanceFor(connection);
        chatManager.addChatListener(chatManagerListener);

When I assign HOST value to my local ip address like 192.168.101.1 and use configBuilder.setServiceName("localhost"); it works perfect but if I assign configBuilder.setServiceName("hostname.com"); and HOST variable to remote server ip address it throws the following error

org.jivesoftware.smack.SmackException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

But if use any xmpp client like gajim I can connect to remote server. I have used the following dependencies

compile 'org.igniterealtime.smack:smack-android-extensions:4.1.3'
compile 'org.igniterealtime.smack:smack-tcp:4.1.3'
Mithun Sarker Shuvro
  • 3,902
  • 6
  • 32
  • 64
  • 1
    Possible duplicate of [Smack: "Trust anchor for certification path not found"](http://stackoverflow.com/questions/32373954/smack-trust-anchor-for-certification-path-not-found) – Flow Nov 09 '16 at 08:42
  • Possible interesting reply: http://stackoverflow.com/questions/2642777/trusting-all-certificates-using-httpclient-over-https/6378872#6378872 – Mickaël Rémond Nov 09 '16 at 10:46

0 Answers0