powered by Jive Software

Catching CertificateException

Hi all, I come across a problem yesterday using smack. I’m creating a connection and specifying into ConnectionConfiguration the option .setNotMatchingDomainCheckEnabled(true). So when I connect to my google app account I have a CertificateException, for host not matching. I want to catch that exception. My aim is to has this exception so I can provide an UI that ask the user to allow this type of connections. I saw in the code of smack that the exception will come into the ConnectionListener:connectionClosedOnError. But when I add that listener to the connection before calling the connect I got IllegalStateException(“Not connected to server.”), which is from the method addConnectionListener. If I add the listener after connect I don’t get this error cause it comes when connecting. I also tried the static listener for global connection creating and its the same as adding the listener after the connect method. So the CertificateException is thrown durring the connect process and cannot be caught, cause the listener can only by added after it is already connected. Any Ideas for solving this? Thanks