【问题标题】:Apache Vysper with Smack 4.1.8 client library - how to handle the TLS certificate?带有 Smack 4.1.8 客户端库的 Apache Vysper - 如何处理 TLS 证书?
【发布时间】:2016-08-05 07:45:05
【问题描述】:

我想使用 Smack 4.1.8 库连接到 Apache Vysper 服务器。但是如何处理 Vysper 自带的 bogus_mina_tls.crt 呢?在 Smack 3 中,您可以使用:

ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration("localhost", 5222);
connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
connectionConfiguration.setSASLAuthenticationEnabled(true);
connectionConfiguration.setKeystorePath("src/main/resources/bogus_mina_tls.cert");
connectionConfiguration.setTruststorePath("src/main/resources/bogus_mina_tls.cert");
connectionConfiguration.setTruststorePassword("boguspw");

但是如何在 Smack 4 API 中使用 XMPPTCPConnectionConfiguration.builder() 做到这一点?

非常感谢

【问题讨论】:

    标签: xmpp smack apache-vysper


    【解决方案1】:

    使用 Smack 4,您需要自己为 Smack 构建 SSLContext 并使用 setCustomSslContext(SSLContext) 进行设置。如果您不提供自定义 SSLContext,那么 Smack 将使用运行时的默认值(即诉诸于使用 Java 的信任库验证证书)。

    【讨论】:

    • 我也需要证书吗?如何设置?你能给我一个教程或类似的东西吗……对不起,我对 ssl 很陌生;)
    猜你喜欢
    • 1970-01-01
    • 2013-04-27
    • 2019-10-25
    • 2018-10-24
    • 2019-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-26
    相关资源
    最近更新 更多