Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issue with QWebsocket Handshake
Forum Updated to NodeBB v4.3 + New Features

Issue with QWebsocket Handshake

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 671 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Justin Pattison-Schmidt
    wrote on last edited by Justin Pattison-Schmidt
    #1

    Qt 5.12.6, openssl 1.1.1c
    I have an issue with QWebsocket handshake failing with error 13.
    First everything works with a CA cert on the server. However, with a self-signed cert on the server I have to do "setPeerVerifyMode(VerifyNone)" for it to work.

    Some debugging:
    I traced to this function:

    bool QSslSocketBackendPrivate::checkSslErrors()
    {
        Q_Q(QSslSocket);
        if (sslErrors.isEmpty())
            return true;
    
        emit q->sslErrors(sslErrors);
    
        bool doVerifyPeer = configuration.peerVerifyMode == QSslSocket::VerifyPeer
                            || (configuration.peerVerifyMode == QSslSocket::AutoVerifyPeer
                                && mode == QSslSocket::SslClientMode);
        bool doEmitSslError = !verifyErrorsHaveBeenIgnored();
        // check whether we need to emit an SSL handshake error
        if (doVerifyPeer && doEmitSslError) {
            if (q->pauseMode() & QAbstractSocket::PauseOnSslErrors) {
                pauseSocketNotifiers(q);
                paused = true;
            } else {
                setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, sslErrors.constFirst().errorString());
                plainSocket->disconnectFromHost();
            }
            return false;
        }
        return true;
    }
    

    verifyErrorsHaveBeenIgnored() is returning false

    bool QSslSocketPrivate::verifyErrorsHaveBeenIgnored()
    {
        bool doEmitSslError;
        if (!ignoreErrorsList.empty()) {
            // check whether the errors we got are all in the list of expected errors
            // (applies only if the method QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)
            // was called)
            doEmitSslError = false;
            for (int a = 0; a < sslErrors.count(); a++) {
                if (!ignoreErrorsList.contains(sslErrors.at(a))) {
                    doEmitSslError = true;
                    break;
                }
            }
        } else {
            // if QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) was not called and
            // we get an SSL error, emit a signal unless we ignored all errors (by calling
            // QSslSocket::ignoreSslErrors() )
            doEmitSslError = !ignoreAllSslErrors;
        }
        return !doEmitSslError;
    }
    

    ignoreAllSslErrors seems to be false even though I am calling ignoreSslErrors(). I call it prior to calling open() as well as sslerror signal

    After tracing it appears that that QSslSocketPrivate::init() is being called in the QSslSocket() constructor as well as in connectToHostEncrypted() which is called in QWebsocket AFTER I set ignoreSslErrors()

    Am I doing something wrong or is this a bug?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From the looks of it your reasoning seems fine.

      Did you check with a more recent version of Qt ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Justin Pattison-Schmidt
        wrote on last edited by
        #3

        I have not.

        aha_1980A 1 Reply Last reply
        0
        • J Justin Pattison-Schmidt

          I have not.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Justin-Pattison-Schmidt Then please do.

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Justin Pattison-Schmidt
            wrote on last edited by
            #5

            Tried with latest 5.14.1, same behavior.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then, you should check the bug report system to see if there's already something related. If not, then please open a new issue with the reasoning you provided here. You can link to this thread but please put the complete explanation on the ticket as links may fail over time while the ticket should not.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved