简体   繁体   中英

Qt server and android ssl client Certificates

I Use Qt as server side,and android as client side. I set in SSLSocketFactory certification

    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();

    }

}

When I want connect to server, in QT is give me that error

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)

http://qt-project.org/doc/qt-5.1/qtnetwork/qsslsocket.html

Look at the description of QSslSocket::sslErrors

Try to hook up sslErrors signal and then call the slot ignoreSslErrors() from there to ignore the errors, that should help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM