[OSX] QSslSocket server with selfsigned cert



  • Hi all,
    I have problem trying to setup QTcpServer with SSL selfsigned certificate.
    I'm working with Qt 5.6.2 .
    The code for the server is quite simple:

    1. QTcpServer subclass
    2. on the incomingConnection I have the following code:
        QSslConfiguration sslConfiguration;
        QSslCertificate certificate(server_cert_pem_ba, QSsl::Pem);
        QSslKey ssl_key(server_pkey_pem_ba, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, key_pwd.toLocal8Bit());
        sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyNone);
        sslConfiguration.setLocalCertificate(certificate);
        sslConfiguration.setPrivateKey(ssl_key);
        sslConfiguration.setProtocol(QSsl::TlsV1SslV3);
    
        QSslSocket *socket = new QSslSocket(this);
        socket->setSslConfiguration(sslCconfiguration);
        socket->setSocketDescriptor(handle);
        connect(socket, SIGNAL(sslErrors(QList<QSslError>)) , this, SIGNAL(sslErrors(QList<QSslError>)));
        socket->startServerEncryption();
        socket->waitForEncrypted();
    

    To test the server I try to connect using a browser to check if it get the certificate:

    https://localhost:my_port
    

    The code works fine when I execute the server on linux.

    On OSX I get the incomingConnection but it never "encrypt".

    May it depend on the fact that I'm using a selfsigned certificate on OSX?
    Does OSX allow this?

    Thanks


Log in to reply