3
votes

For integration testing of my xmpp stack I set up a vysper server (0.7) on localhost. Now I want to connect to the server using smack-core and smack-tcp in version 4.0.2.

Problem:

Caused by: javax.net.ssl.SSLHandshakeException:
    sun.security.validator.ValidatorException: PKIX path building failed:
    sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Since the smack 4 api has changed a lot, the examples found so far can not be used anymore. Anyone tried this before?

1
Please note that Smack 4.0.3 is the current up-to-date version. But this isn't related to the Exception.Flow
Thanks for the hint ... but 4.0.3 doesn't seem to be available on central: mvnrepository.com/artifact/org.igniterealtime.smack/smack-coreJan Galinski
Thanks for pointing this out, 4.0.3 has been released to central and will be available soon.Flow

1 Answers

7
votes

The SSLHandashskeException tells us that the SSL/TLS handshake has failed, which is because there was a ValidatorException that tells us that the "PKIX path building failed", because there was a SunCertPathBuilderException thrown because the Java API was "unable to find valid certification path to requested target".

The Java API (ie. this is not done by Smack) could not build a valid certificate chain to the servers SSL/TLS certificate with the active SSLContext. That is why this exception is thrown. You need to provide either a valid certifcate (however that is defined by your currently used SSLContext) or tell Smack to use a SSLContext (ConnectionConfiguration.setCustomSSLContext(SSLContext)) that accepts your current server certificate