【问题标题】:hava jabber-bot. XMPP over smack 4.2.0 with TLShava jabber-bot。 XMPP over smack 4.2.0 with TLS
【发布时间】:2017-04-27 07:44:27
【问题描述】:

我需要开发迷你 jabber-bot。我有一个只有 TLS 连接规则的 openfire 服务器。我曾经 smack 4.2.0 - 来自http://www.igniterealtime.org/downloads/ 的最后一个稳定版本我尝试连接但有一个例外: 代码:

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                .setUsernameAndPassword("testjava", "12345678")
                .setServiceName(server)
                .setPort(5222)
                .setHost(server)                    .setSecurityMode(ConnectionConfiguration.SecurityMode.required)
                .setDebuggerEnabled(true)
                .build();

        AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);

        conn2.connect();

日志:

10:35:31 AM SENT (0): <stream:stream xmlns='jabber:client' to='***.pro' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='testjava@***.pro' xml:lang='en'>
10:35:31 AM RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="***.pro" id="xb9bamjxw" xml:lang="en" version="1.0">
10:35:32 AM RECV (0): <stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanisms></stream:features>
10:35:32 AM SENT (0): <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>
10:35:32 AM RECV (0): <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
Exception in thread "main" org.jivesoftware.smack.SmackException: 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
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1010)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:937)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:952)
    at java.lang.Thread.run(Thread.java:745)

我使用 Pidgin 并已建立与服务器的连接。我需要在我的代码中添加什么来支持 TLS 身份验证?

【问题讨论】:

标签: java xmpp smack


【解决方案1】:

您的服务器似乎没有“有效”证书。购买有效证书,或将库配置为允许“不受信任”证书。

【讨论】:

    猜你喜欢
    • 2017-09-20
    • 2016-02-09
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    • 2023-03-25
    • 2015-01-20
    • 1970-01-01
    • 2011-09-29
    相关资源
    最近更新 更多