如何使用Smack XMPP库创建SSL连接? [英] How to create an SSL connection using the Smack XMPP library?

查看:204
本文介绍了如何使用Smack XMPP库创建SSL连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个充当XMPP客户端的小程序,我正在使用 Smack 库。现在,我连接的服务器需要SSL(在Pidgin中我必须检查强制旧(端口5223)SSL)。我无法让Smack连接到这台服务器。有可能吗?

I'm building a small program that acts as an XMPP client and I am using the Smack library. Now, the server I am connecting to requires SSL (in Pidgin I have to check "Force old (port 5223) SSL"). I'm having trouble getting Smack to connect to this server. Is it possible?

推荐答案

看一下这个帖子。

http://www.igniterealtime.org/community/thread/37678

基本上,您需要将这两行添加到您的代码中:

Essentially, you need to add these two lines to your code:

connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
connConfig.setSocketFactory(new DummySSLSocketFactory());

其中connConfig是您的ConnectionConfiguration对象。从Spark源代码存储库中获取DummySSLSocketFactory。它所做的只是接受任何证书。这似乎对我有用。祝你好运!

where connConfig is your ConnectionConfiguration object. Get the DummySSLSocketFactory from the Spark source code repository. All it does is accept virtually any certificate. This seemed to work for me. Good luck!

这篇关于如何使用Smack XMPP库创建SSL连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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