Smack 4 throws “SSLHandshakeException: ValidatorException: SunCertPathBuilderException” on connect

▼魔方 西西 提交于 2019-12-06 07:05:44

问题


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:


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



来源:https://stackoverflow.com/questions/25495368/smack-4-throws-sslhandshakeexception-validatorexception-suncertpathbuilderexc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!