gpt4 book ai didi

java - ejabberd 和 smack 握手失败

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:13:32 24 4
gpt4 key购买 nike

我在我的云服务器上运行 ejabberd,我认为它运行良好,因为我可以使用 pidgin 从我的 PC 连接到它。(ejabberdctl connected-users-number连接时回答 1,离线时回答 0。)

现在我尝试使用 smack 包从我的 android 应用程序连接到 if,我得到 IOException :

javax.net.ssl.SSLHandshakeException: Handshake failed

Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb897c858: Failure in SSL library, usually a protocol error
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:795 0xacf6bf89:0x00000000)
W/System.err﹕ at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:318)

这是我的应用程序代码:

XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
config.setConnectTimeout(30000);
config.setUsernameAndPassword(username + "@" + service, password);
config.setServiceName(service);
config.setHost(host);
config.setCompressionEnabled(true);
config.setPort(port);
config.setDebuggerEnabled(true);
config.setSocketFactory(SSLSocketFactory.getDefault());

SmackConfiguration.DEBUG = true;
try {
TLSUtils.acceptAllCertificates(config);
XMPPTCPConnection connection = new XMPPTCPConnection(config.build());
connection.connect();
connection.login();

} catch (SmackException ex) {
ex.printStackTrace();
chatClient.setConnection(null);
} catch(IOException ex){
ex.printStackTrace();
chatClient.setConnection(null);
} catch ( XMPPException ex){
ex.printStackTrace();
chatClient.setConnection(null);
}catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
chatClient.setConnection(null);
}catch (KeyManagementException ex) {
ex.printStackTrace();
chatClient.setConnection(null);
}
return null;

如果有任何帮助,我将不胜感激!

最佳答案

如果您的服务器未启用 SSL,请禁用 SSL。要禁用,

config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

关于java - ejabberd 和 smack 握手失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31263403/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com