0

我设法通过 asmack 连接到我的 XMPP 服务器,但连接后我看到 NullPointerException 警告。我将 carcets.bks 文件放在 raw 文件夹中。这个警告重要吗?

the logcat show:

java.lang.NullPointerException
at java.io.File.fixSlashes(File.java:185)
at java.io.File.<init>(File.java:134)
at java.io.FileInputStream.<init>(FileInputStream.java:105)
at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:62)
at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:839)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:268)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:71)


   this is my connection :

    configure(ProviderManager.getInstance());
    config = new ConnectionConfiguration(server, port);
    config.setCompressionEnabled(true);
    config.setSecurityMode(SecurityMode.enabled);
    config.setSASLAuthenticationEnabled(true);

    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");
        path = System.getProperty("java.home") + File.separator + "etc"
                + File.separator + "security" + File.separator
                + "cacerts.bks";
        config.setTruststorePath(path);
    }
    connection = new XMPPConnection(config);
    connection.connect();
4

1 回答 1

0

您的问题是信任存储路径。查找路径时会发生异常。

您是否达到构建版本的第一个条件?在这种情况下,路径设置为 null。

于 2013-09-24T02:37:26.723 回答