openfire

记录一下使用openfire开发即时通讯时遇到的问题:

1、安装openfire;

 

2、使用smack类库连接openfire:

在连接的时候如果报错如下:

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

说明你需要按照openfire的证书。

 

安装证书方法:

参考https://issues.jenkins-ci.org/browse/JENKINS-22082

在openfire的安装目录Openfire\resources\security下,使用OpenSSL s_client -connect 10.133.17.108:5223可以查看到证书:


 

拷贝红框里的证书保存到本地命名为openfire.cer。

然后在%JAVA_HOME%\jre\lib\security的目录下使用命令 keytool -import -alias cacerts -keystore cacerts -file D:/openfire.cer -trustcacerts -alias openfire导入证书。(openfire为别名)

 

3、登录openfire

conn.login();

报错:org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized
说明账号密码不对。

报错:org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected说明链接被断开。