我已经为带有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);