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. QNetworkAccessManager and HTTPS
Forum Updated to NodeBB v4.3 + New Features

QNetworkAccessManager and HTTPS

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 5.6k Views 1 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.
  • A Offline
    A Offline
    antonio
    wrote on last edited by
    #1

    Hello,

    I'm a newbie at SSL and https... I need to send files by Https... I've searched about how to use of QNetworkAccessManager, QNetworkRequest, QHttpMultipart, QnetworkReply and QSslSocket for working together without any success. Can you give me some guide about it?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Code_ReaQtor
      wrote on last edited by
      #2

      Try to install an SSL library, "OpenSSL":http://www.openssl.org/

      Please visit my open-source projects at https://github.com/Code-ReaQtor.

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        Are you using the source version of Qt? Mening you compile your Qt yourself?
        If so you need to download precompiled OpenSSL libraries or compile them yourself. And reconfigure and recompile Qt.
        AFAIK the prebuild Qt releases should already have OpenSSL integrated.

        Please tell us what exactly didn't work out for you. Also there a many resources on the web how to use ssl in your Qt application.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • A Offline
          A Offline
          antonio
          wrote on last edited by
          #4

          Hello this is part of my code,

          @
          QFile certFile("./ca.crt");
          if(!certFile.open(QIODevice::ReadOnly))
          qDebug() <<certFile.fileName() << " not opened";
          QByteArray arrayCert = certFile.readAll();
          QSslCertificate cert(arrayCert, QSsl::Pem);

          qDebug() << "null: " << cert.isNull() << " valid: " << cert.isValid() ;

          QSslSocket *sslSocket = new QSslSocket(this);
          sslSocket->addCaCertificate(cert);
          QSslConfiguration config = sslSocket->sslConfiguration();
          sslSocket->setSslConfiguration(config);
          request.setSslConfiguration(config);
          @

          After that, I added some headers and a file.... then

          I send:
          @
          reply = manager->post(request, multiPart);
          @

          after that I get this errors:

          err: "The issuer certificate of a locally looked up certificate could not be found"
          err: "The root CA certificate is not trusted for this purpose"
          err: "No certificates could be verified"

          I supouse that my ssl config is bad.

          Regads

          1 Reply Last reply
          0
          • U Offline
            U Offline
            updatenode
            wrote on last edited by
            #5

            Hi,

            are you sure your certificate is encoding using Qt::Pem format? OR is it QSsl::Der?

            We had same issues and the reason was that we have extracted the certificate as DER encoded and passed Qt::Pem.

            Other than that, make sure you have all SSL dependencies installed and check your code again. Usually it's not need to define a QSslSocket if your are using the QNetworkManager.

            We are setting the root CA from geotrust just in case its not available:

            @
            QSslConfiguration defaultSSLConfig = QSslConfiguration::defaultConfiguration();
            QList<QSslCertificate> certificates = defaultSSLConfig.caCertificates();
            QFile cert;
            cert.setFileName(":/cert/geotrust.cer");
            if(cert.open(QIODevice::ReadOnly))
            {
            QSslCertificate certificate(&cert, QSsl::Der);
            certificates.append(certificate);
            }
            defaultSSLConfig.setCaCertificates(certificates);
            QSslConfiguration::setDefaultConfiguration(defaultSSLConfig);
            @

            afterwards you can access your server with QNetworkManager and QWebKit.

            Hope that helps

            Good Luck!

            1 Reply Last reply
            0

            • Login

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