3

皆さんこんにちは。サーバー側とクライアント側の両方で、JavaでXMPPを少し使い始めました。サーバー側では Apache Vysper 0.7 を使用し、クライアント側では Ignite Smack 3.1.0 を使用しています。ソース コードに付属の TLS 証明書を使用して、Apache vysper デモ ページの小さな XMPP 組み込みサーバーを使用しています。

    XMPPServer server = new XMPPServer("localhost");  

    StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();  

    AccountManagement accountManagement = (AccountManagement) providerRegistry.retrieve(AccountManagement.class);  

    Entity user = EntityImpl.parseUnchecked("user@localhost");  
    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 で同じことを行うことですが、方法がわかりません。

私のsmack apiでは、次のようなものを使用しています:

    ConnectionConfiguration config = new ConnectionConfiguration("localhost",5222, "localhost");
    config.setSASLAuthenticationEnabled(false);

    connection = new XMPPConnection(config);
    connection.connect();

    connection.login(userName, password);

それで、ここにあります。無効な証明書を承認または拒否するにはどうすればよいですか? ご協力いただきありがとうございます。

4

2 に答える 2

6

Apache Vysper での統合テストでは、次のようなものを使用します。

ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration("localhost", 5222);
connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
connectionConfiguration.setSASLAuthenticationEnabled(true);
connectionConfiguration.setKeystorePath("src/main/resources/bogus_mina_tls.cert");
connectionConfiguration.setTruststorePath("src/main/resources/bogus_mina_tls.cert");
connectionConfiguration.setTruststorePassword("boguspw");

例を参照してください。 AbstractIntegrationTestCase.java

于 2011-04-19T13:01:32.743 に答える
1

私はあなたが探していると思います

config.setSelfSignedCertificateEnabled(true)
于 2011-04-19T07:22:37.273 に答える