我使用Qt
作为服务器端,android
作为客户端。
我设置了SSLSocketFactory
认证
private ConnectionManager(MBoxConfiguration config) {
try {
this.config = config;
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
SSLSocketFactory sf = new SSLSocketFactory(trusted);
Socket socket;
socket = ssf.createSocket();
socket.connect(new InetSocketAddress(config.ip, config.port));
KeyStore trusted = KeyStore.getInstance("BKS");
InputStream in = MainActivity.context.getResources().openRawResource(R.raw.truststore);
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
ssf = new SSLSocketFactory(trusted);
ssf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
} catch (Exception e) {
e.printStackTrace();
}
}
当我想要连接到服务器时,在QT
中给出了我的错误
Thread Address in peerVerifyError "The peer did not present any certificate"
Thread Address in sslErrors ("The peer did not present any certificate")
Thread Address in error QAbstractSocket::SocketError( 13 )
Thread Address in destroyThreadfirst: QThread(0x12ec9448)
Thread Address in destroyThread: QThread(0x12ec9238)
答案 0 :(得分:0)
http://qt-project.org/doc/qt-5.1/qtnetwork/qsslsocket.html
查看QSslSocket :: sslErrors的描述
尝试连接sslErrors
信号,然后从那里调用插槽ignoreSslErrors()
以忽略错误,这应该会有所帮助。