在连接到Starttls配置XMPP服务器时发出问题
题
我已为具有CA证书的STARTTLS配置EJABBERD服务器。 以下是配置:
{5222, ejabberd_c2s, [
{access, c2s},
{shaper, c2s_shaper},
starttls_required,
{certfile, "/etc/ejabberd/conf/ejabberd.pem"},
{max_stanza_size, 65536}
]},
.
我的XMPP客户端已经在Java中使用Smack库开发。 我希望我的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);
.
即使我在truststore中提供伪证书,它也成功地进行了连接。
我错过了什么吗?
解决方案
尝试
config.setVerifyRootCAEnabled(true);
. 不隶属于 StackOverflow