我已经使用 CA 证书为 StartTLS 配置了 ejabberd 服务器。 下面是配置:
{5222, ejabberd_c2s, [
{access, c2s},
{shaper, c2s_shaper},
starttls_required,
{certfile, "/etc/ejabberd/conf/ejabberd.pem"},
{max_stanza_size, 65536}
]},
我的 XMPP 客户端是使用 Smack 库用 java 开发的。 我希望我的 XMPP 客户端仅在证书有效时才能与服务器一起使用。但我做不到。 下面是我的 XMPP 客户端代码
ConnectionConfiguration config = new ConnectionConfiguration(host, port, serviceName);
config.setSASLAuthenticationEnabled(true);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
config.setCompressionEnabled(true);
config.setTruststorePath(trustStorePath);
config.setTruststorePassword(trustStorePwd);
config.setExpiredCertificatesCheckEnabled(true);
config.setNotMatchingDomainCheckEnabled(true);
config.setVerifyChainEnabled(true);
即使我在信任库中提供虚拟证书,它也会成功建立连接。
我错过了什么吗?
最佳答案
尝试
config.setVerifyRootCAEnabled(true);
关于java - 连接到 StartTLS 配置的 XMPP 服务器时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21016812/