1

我已经为 StartTLS 配置了带有 CA 证书的 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);

即使我在信任库中提供了一个虚拟证书,它也会成功建立连接。

我错过了什么吗?

4

1 回答 1

1

尝试

config.setVerifyRootCAEnabled(true);
于 2014-01-09T16:02:45.927 回答