3
votes

HI everyone. I've just started to play a little with XMPP in java, both server and client side. On the server side I'm using Apache Vysper 0.7 and on client side I'm using Ignite Smack 3.1.0 I'm using a small XMPP embedded server from the apache vysper demo page using a TLS certificate that comes with the source code:

    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...");

The problem is that this is not a correct/valid certificate. If I test my server using pidgin an alert window pops up and tells me the certificate is invalid and a button in case I want to add an exception for this.

What I want is to do the same thing with the Smack api, but I don't know how.

on my smack api I'm using something like this:

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

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

    connection.login(userName, password);

So here it is. What do I need to do to accept or decline invalid certificates ? Thanks for your help.

2

2 Answers

6
votes

In the integration tests in Apache Vysper, we use something like:

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");

See for example: https://svn.apache.org/repos/asf/mina/vysper/trunk/server/core-inttest/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/AbstractIntegrationTestCase.java

1
votes

I think you are looking for

config.setSelfSignedCertificateEnabled(true)