QSslSocket error without sslErrors emited



  • Hello,

    i've got a QTcpServer which listens on a port. I've implemented the oncommingConnection function like that:

    SslConnection *pSsl = new SslConnection();
    if(pSsl->setSocketDescriptor(socketDescriptor))
    {
       QObject::connect(pSsl, SIGNAL(sslErrors(QList<QSslError>)),
                        this, SLOT(sslError(QList<QSslError>)));
       QObject::connect(pSsl, SIGNAL(error(QAbstractSocket::SocketError)),
                        this, SLOT(error(QAbstractSocket::SocketError)));
       pSsl->startServerEncryption();
       pSsl->waitForEncrypted(2000);
       qDebug() << "SslError:" << pSsl->sslErrors();
    }
    else
    {
       delete pSsl;
    }
    

    SslConnection is just a QSslSocket, nothing special in it yet. Both slots just print the errors using qDebug(), nothing special in them too.
    The error from the error()-slot i receive is:

    SocketError: QAbstractSocket::SocketTimeoutError
    SocketError: QAbstractSocket::SocketError( 13 )

    the SocketError(13) is a

    QAbstractSocket::SslHandshakeFailedError

    but my sslError-slot doesn't receive any error at all. The qDebug() i added at the end prints an empty list.
    Why does the QAbstractSocket tell me about an Ssl Error while the QSslSocket doesn't provide me further informations or errors at all?

    Maybe helpful:

    • Qt 5.4 on Windows
    • OpenSSL 1.0.2a
    • QSslSocket::supportsSsl() returns true


  • It's because Qt (or rather QSslSocket) closes the connection immediately after emitting the error() signal.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.