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. HTTPS with QNetworkAccessManager not working

HTTPS with QNetworkAccessManager not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 2.4k Views
  • 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.
  • D Offline
    D Offline
    Dave P.
    wrote on last edited by
    #1

    This is a thread that I am trying to get https working in and I can't.. Help please!

    MyHttpsThread::MyHttpsThread(QObject *parent) :
    QThread(parent)
    {
    }

    MyHttpsThread::~MyHttpsThread()
    {
    m_mutex.lock();
    m_quit = true;
    m_mutex.unlock();
    wait();
    }

    void MyHttpsThread::startMyHttpsThread(void)
    {

    const QMutexLocker locker(&m_mutex);
    //m_serror = error;
    
    
    if (!isRunning())
        start();
    

    }

    void MyHttpsThread::run()
    {
    qDebug() << "MyHttpsThread started";

    QNetworkRequest netRequest;
    QSslConfiguration sSlConfig;
    
    netManager = new QNetworkAccessManager();
    
    sSlConfig.setDefaultConfiguration(QSslConfiguration::defaultConfiguration());
    sSlConfig.setProtocol(QSsl::TlsV1_2);
    netRequest.setSslConfiguration(sSlConfig);
    netRequest.setUrl(QUrl("https://tlsinfo.nails.eu.org"));
    
    connect(netManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    //connect(netManager, SIGNAL(error(QNetworkReply*, QNetworkReply::NetworkError&)), this, SLOT(errorReturned(QNetworkReply*, QNetworkReply::NetworkError&)));
    connect(netManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&)));
    netManager->get(netRequest);
    
    while (!m_quit) {
        QThread::msleep(1);
    }   // while (!m_quit)
    

    }

    void MyHttpsThread::replyFinished(QNetworkReply* reply)
    {
    int ii;
    QByteArray data = reply->readAll();
    ii = 0;
    }

    void MyHttpsThread::errorReturned(QNetworkReply*, QNetworkReply::NetworkError &err)
    {
    int ii;
    ii = 0;
    }

    void MyHttpsThread::onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors)
    {
    int ii;
    ii = 0;
    }

    JKSHJ 1 Reply Last reply
    0
    • D Dave P.

      This is a thread that I am trying to get https working in and I can't.. Help please!

      MyHttpsThread::MyHttpsThread(QObject *parent) :
      QThread(parent)
      {
      }

      MyHttpsThread::~MyHttpsThread()
      {
      m_mutex.lock();
      m_quit = true;
      m_mutex.unlock();
      wait();
      }

      void MyHttpsThread::startMyHttpsThread(void)
      {

      const QMutexLocker locker(&m_mutex);
      //m_serror = error;
      
      
      if (!isRunning())
          start();
      

      }

      void MyHttpsThread::run()
      {
      qDebug() << "MyHttpsThread started";

      QNetworkRequest netRequest;
      QSslConfiguration sSlConfig;
      
      netManager = new QNetworkAccessManager();
      
      sSlConfig.setDefaultConfiguration(QSslConfiguration::defaultConfiguration());
      sSlConfig.setProtocol(QSsl::TlsV1_2);
      netRequest.setSslConfiguration(sSlConfig);
      netRequest.setUrl(QUrl("https://tlsinfo.nails.eu.org"));
      
      connect(netManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
      //connect(netManager, SIGNAL(error(QNetworkReply*, QNetworkReply::NetworkError&)), this, SLOT(errorReturned(QNetworkReply*, QNetworkReply::NetworkError&)));
      connect(netManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&)));
      netManager->get(netRequest);
      
      while (!m_quit) {
          QThread::msleep(1);
      }   // while (!m_quit)
      

      }

      void MyHttpsThread::replyFinished(QNetworkReply* reply)
      {
      int ii;
      QByteArray data = reply->readAll();
      ii = 0;
      }

      void MyHttpsThread::errorReturned(QNetworkReply*, QNetworkReply::NetworkError &err)
      {
      int ii;
      ii = 0;
      }

      void MyHttpsThread::onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors)
      {
      int ii;
      ii = 0;
      }

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @Dave-P. said in HTTPS with QNetworkAccessManager not working:

      I am trying to get https working in and I can't..

      Please provide more details: What doesn't work? What error messages do you get?

      Anyway, Qt requires OpenSSL to use HTTPS. Have you installed OpenSSL 1.0.2 and put it in a PATH that your app can find?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      D 1 Reply Last reply
      1
      • JKSHJ JKSH

        @Dave-P. said in HTTPS with QNetworkAccessManager not working:

        I am trying to get https working in and I can't..

        Please provide more details: What doesn't work? What error messages do you get?

        Anyway, Qt requires OpenSSL to use HTTPS. Have you installed OpenSSL 1.0.2 and put it in a PATH that your app can find?

        D Offline
        D Offline
        Dave P.
        wrote on last edited by
        #3

        @JKSH Hi,

        I did install the latest openssl but because of homebrew issues it had to be installed at: /Users/davidpatton1/scratch/openssl

        Here is the openssl version -a output...
        OpenSSL 1.1.1-pre9-dev xx XXX xxxx
        built on: Tue Jul 17 03:10:57 2018 UTC
        platform: darwin64-x86_64-cc
        options: bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
        compiler: cc -fPIC -arch x86_64 -Wa,--noexecstack -Qunused-arguments -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPADLOCK_ASM -DPOLY1305_ASM -D_REENTRANT -DNDEBUG -I/usr/local/opt/openssl/include
        OPENSSLDIR: "/usr/local/ssl"
        ENGINESDIR: "/usr/local/lib/engines-1.1"
        Seeding source: os-specific

        By not working I mean that neither the: void MyHttpsThread::replyFinished(QNetworkReply* reply) nor the void MyHttpsThread::onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors)

        routines are ever hit. Opening https://tlsinfo.nails.eu.org in my browser works fine..

        Thanks..

        JKSHJ 1 Reply Last reply
        0
        • D Dave P.

          @JKSH Hi,

          I did install the latest openssl but because of homebrew issues it had to be installed at: /Users/davidpatton1/scratch/openssl

          Here is the openssl version -a output...
          OpenSSL 1.1.1-pre9-dev xx XXX xxxx
          built on: Tue Jul 17 03:10:57 2018 UTC
          platform: darwin64-x86_64-cc
          options: bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
          compiler: cc -fPIC -arch x86_64 -Wa,--noexecstack -Qunused-arguments -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPADLOCK_ASM -DPOLY1305_ASM -D_REENTRANT -DNDEBUG -I/usr/local/opt/openssl/include
          OPENSSLDIR: "/usr/local/ssl"
          ENGINESDIR: "/usr/local/lib/engines-1.1"
          Seeding source: os-specific

          By not working I mean that neither the: void MyHttpsThread::replyFinished(QNetworkReply* reply) nor the void MyHttpsThread::onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors)

          routines are ever hit. Opening https://tlsinfo.nails.eu.org in my browser works fine..

          Thanks..

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @Dave-P. said in HTTPS with QNetworkAccessManager not working:

          OpenSSL 1.1.1-pre9-dev xx XXX xxxx

          OpenSSL v1.1 is incompatible with OpenSSL v1.0.2.

          For now, try installing v1.0.2 to check if it works.

          After that, if you want to use v1.1, I think you need to rebuild Qt to link against OpenSSL v1.1

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          4

          • Login

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