无法使用Asmack连接到我的ejabberd服务器

时间:2014-06-26 06:44:24

标签: android keystore ejabberd asmack sasl

在logcat中获取这些错误:

06-26 02:34:08.352:W / System.err(1261):java.security.KeyStoreException:java.security.NoSuchAlgorithmException:未找到KeyStore jks实现 06-26 02:34:08.352:W / System.err(1261):at java.security.KeyStore.getInstance(KeyStore.java:119) 06-26 02:34:08.352:W / System.err(1261):at org.jivesoftware.smack.ServerTrustManager。(ServerTrustManager.java:71) 06-26 02:34:08.352:W / System.err(1261):at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:858) 06-26 02:34:08.352:W / System.err(1261):at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:250) 06-26 02:34:08.352:W / System.err(1261):at org.jivesoftware.smack.PacketReader.access $ 000(PacketReader.java:46) 06-26 02:34:08.362:W / System.err(1261):at org.jivesoftware.smack.PacketReader $ 1.run(PacketReader.java:72) 06-26 02:34:08.362:W / System.err(1261):引起:java.security.NoSuchAlgorithmException:未找到KeyStore jks实现 06-26 02:34:08.362:W / System.err(1261):at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177) 06-26 02:34:08.362:W / System.err(1261):at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151) 06-26 02:34:08.362:W / System.err(1261):at java.security.KeyStore.getInstance(KeyStore.java:116) 06-26 02:34:08.362:W / System.err(1261):... 5 more

06-26 02:34:09.802:W / System.err(1261):使用机制DIGEST-MD5进行SASL身份验证失败: 06-26 02:34:09.802:W / System.err(1261):at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:341) 06-26 02:34:09.802:W / System.err(1261):at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:242) 06-26 02:34:09.802:W / System.err(1261):at org.jivesoftware.smack.Connection.login(Connection.java:371) 06-26 02:34:09.802:W / System.err(1261):at com.example.contactupdater.MainActivity $ MainActivity2.login(MainActivity.java:358) 06-26 02:34:09.802:W / System.err(1261):at com.example.contactupdater.MainActivity $ MainActivity2.login(MainActivity.java:347) 06-26 02:34:09.802:W / System.err(1261):at com.example.contactupdater.MainActivity $ 1.run(MainActivity.java:320)

1 个答案:

答案 0 :(得分:2)

这是这个问题的答案......

AndroidConnectionConfiguration config = new AndroidConnectionConfiguration(server,
                port);
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            config.setTruststoreType("AndroidCAStore");
            config.setTruststorePassword(null);
            config.setTruststorePath(null);
        } else {
            config.setTruststoreType("BKS");
            String path = System.getProperty("javax.net.ssl.trustStore");
            if (path == null)
                path = System.getProperty("java.home") + File.separator + "etc"
                    + File.separator + "security" + File.separator
                    + "cacerts.bks";
            config.setTruststorePath(path);
        }