嗨,大家好。我剛剛開始在Java中使用XMPP,包括服務器端和客戶端。 在服務器端,我使用的是Apache Vysper 0.7,在客戶端,我使用的是Ignite Smack 3.1.0 我使用的是apache vysper演示頁面中的一個小型XMPP嵌入式服務器,它使用源代碼隨附的TLS證書代碼:如何使用java中的Smack XMPP庫處理TLS證書
XMPPServer server = new XMPPServer("localhost");
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("bogus_mina_tls.cert"), "boguspw");
server.start();
System.out.println("Vysper server is running...");
問題是這不是一個正確/有效的證書。如果我使用pidgin測試服務器,會彈出一個警告窗口,告訴我證書無效,並且在我想爲此添加例外時使用按鈕。
我想要的是用Smack API做同樣的事情,但我不知道如何。
我嫌API我使用的是這樣的:
ConnectionConfiguration config = new ConnectionConfiguration("localhost",5222, "localhost");
config.setSASLAuthenticationEnabled(false);
connection = new XMPPConnection(config);
connection.connect();
connection.login(userName, password);
所以這裏。我需要做什麼來接受或拒絕無效的證書? 感謝您的幫助。
謝謝。你的例子可以幫助我,因爲它不會再傷害我的xmpp客戶端,但是我正在尋找的是類似於pidgin處理這種情況的方法。例如:如果(證書有效){做某事}其他{顯示警告與接受拒絕} – 2011-04-19 22:55:26
任何想法如何使用smack 4 api做到這一點? – 2014-08-25 22:41:56