Smack 4 throws "SSLHandshakeException: ValidatorException: SunCertPathBuilderException" on connection
To test the integration of my xmpp stack, I have installed vysper (0.7) server on localhost. Now I want to connect to the server using smack-core and smack-tcp in 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 no longer be used. Has anyone tried this before?
source to share
SSLHandashskeException
tells us that the SSL / TLS handshake failed because there was ValidatorException
, which tells us that "PKIX path building failed failed" because it was called SunCertPathBuilderException
because the Java API "could not find a valid certification path for the requested purpose."
The Java API (i.e. this is not done by Smack) was unable to create a valid certificate chain for the SSL / TLS server certificate with an active SSLContext. This is why this is an exception. You need to provide either a valid certifcate (however this is determined by your currently used SSLContext) or tell Smack to use SSLContext ( ConnectionConfiguration.setCustomSSLContext(SSLContext)
) which accepts your current server certificate
source to share