我在做一個vysper xmpp服務器。 這裏是我的代碼:vysper服務器登錄失敗
public static void main(String[] args) throws Exception {
XMPPServer server = new XMPPServer("myserver.org");
StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();
AccountManagement accountManagement = (AccountManagement) providerRegistry.retrieve(AccountManagement.class);
Entity user = EntityImpl.parseUnchecked("[email protected]");
accountManagement.addUser(user, "password");
server.setStorageProviderRegistry(providerRegistry);
server.addEndpoint(new TCPEndpoint())
server.setTLSCertificateInfo(new File("keystore.jks"), "boguspw");
//server.setTLSCertificateInfo(new File("bogus_mina_tls.cert"), "boguspw");
server.start();
System.out.println("Vysper server is running...");
server.addModule(new EntityTimeModule());
server.addModule(new VcardTempModule());
server.addModule(new XmppPingModule());
server.addModule(new PrivateDataModule());
}
我都試過證書文件。 (keystore.jks,bogus_mina_tls.cert)
我啓動服務器後,它連接到它,並嘗試登錄但無法登錄。
SmackConfiguration.setPacketReplyTimeout(5000);
config = new ConnectionConfiguration("myserver.org", port, "localhost");
config.setSelfSignedCertificateEnabled(true);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
config.setSASLAuthenticationEnabled(true);
// config.setKeystorePath(「keystore.jks」);
// config.setTruststorePath(「keystore.jks」);
config.setKeystorePath("bogus_mina_tls.cert");
config.setTruststorePath("bogus_mina_tls.cert");
config.setTruststorePassword("boguspw");
XMPPConnection.DEBUG_ENABLED = true;
connection = new XMPPConnection(config);
try {
connection.connect();
} catch (XMPPException e) {
System.out.println("Error connect");
e.printStackTrace();
}
System.out.println("Connected: " + connection.isConnected());
try {
System.out.println(connection.isAuthenticated());
connection.login("user", "password");
} catch (XMPPException e) {
System.out.println("Error login");
e.printStackTrace();
}
我捕獲這個異常:
SASL認證平原失敗:編碼不正確,:在 org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:337) 在 組織。 jfsoftware.smack.XMPPConnection.login(XMPPConnection.java:203) at org.jivesoftware.smack.Connection.login(Connection.java:348)at com.protocol7.vysper.intro.WorkingClient.init(WorkingClient.java: 57) at com。 protocol7.vysper.intro.WorkingClient(WorkingClient.java:27) 在com.protocol7.vysper.intro.Runclient.main(Runclient.java:11)