Smack 4抛出“SSLHandshakeException:ValidatorException:SunCertPathBuilderException”在连接上 [英] Smack 4 throws "SSLHandshakeException: ValidatorException: SunCertPathBuilderException" on connect

查看:139
本文介绍了Smack 4抛出“SSLHandshakeException:ValidatorException:SunCertPathBuilderException”在连接上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的xmpp堆栈的集成测试,我在localhost上设置了一个vysper服务器(0.7)。
现在我想在版本4.0.2中使用smack-core和smack-tcp连接到服务器。

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.

问题:

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

自打击以来4 api已经改变很多,到目前为止发现的例子已经不能再使用了。
以前有人试过这个吗?

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

推荐答案

SSLHandashskeException 告诉我们SSL / TLS握手失败,这是因为有一个 ValidatorException 告诉我们PKIX路径构建失败,因为有一个抛出SunCertPathBuilderException ,因为Java API无法找到所请求目标的有效证书路径。

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

Java API(即this不是由Smack完成的)无法使用活动SSLContext为服务器SSL / TLS证书构建有效的证书链。这就是抛出此异常的原因。您需要提供有效的证书(但是由您当前使用的SSLContext定义)或告诉Smack使用接受您的SSLContext( ConnectionConfiguration.setCustomSSLContext(SSLContext))当前服务器证书

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

这篇关于Smack 4抛出“SSLHandshakeException:ValidatorException:SunCertPathBuilderException”在连接上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆