我需要开发迷你jabber-bot。我有一个只有TLS连接规则的openfire服务器。我曾经打过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身份验证?
答案 0 :(得分:-1)
看起来您的服务器没有“有效”的服务。证书。购买有效的证书,或配置库以允许“不受信任的”#39;证书。