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. MAC osX SSL issue SSLRead failed: -9842
Forum Updated to NodeBB v4.3 + New Features

MAC osX SSL issue SSLRead failed: -9842

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 653 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.
  • I Offline
    I Offline
    ieio
    wrote on last edited by
    #1

    Hi all,
    I am new to QT-SSL, I started the http example and I added the following member function:
    bool HttpWindow::loadPfxCertifcate2( ) {

    QFile certFile("/Users/ieio/Qt/Examples/Qt-5.7/network/build-http-Desktop_Qt_5_7_0_clang_64bit-Debug/clientcert.pem");
    if(!certFile.open(QFile::ReadOnly))
    {
        QMessageBox::warning(this, tr("Http"),
                                       tr("Unable to open Cert file"),
                                       QMessageBox::Cancel);
        return false;
    }
    
    
    QSslCertificate certificate(&certFile, QSsl::Pem);
    certFile.close();
    

    &importedCerts, QByteArray::fromStdString(passphrase.toStdString()))

    certFile.setFileName("/Users/ieio/Qt/Examples/Qt-5.7/network/build-http-Desktop_Qt_5_7_0_clang_64bit-Debug/cacert.pem");
    certFile.open(QFile::ReadOnly);
    QSslCertificate caCert(&certFile);
    certFile.close();
    
    
    
    QFile keyFile("/Users/ieio/Qt/Examples/Qt-5.7/network/build-http-Desktop_Qt_5_7_0_clang_64bit-Debug/privkey.key");
    keyFile.open(QFile::ReadOnly);
    QSslKey key(&keyFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "changeit");
    qWarning() << key.isNull();
    
    keyFile.close();
    
    QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
    QList<QSslCertificate> certs = sslConfig.caCertificates();
    QList<QSslCertificate> localCerts = sslConfig.localCertificateChain();
    
    localCerts.append(certificate);
    certs.append(caCert);
    
    sslConfig.setLocalCertificateChain(localCerts);
    sslConfig.setCaCertificates(certs);
    sslConfig.setPrivateKey(key);
    
     QSslConfiguration::setDefaultConfiguration(sslConfig);
    
    return 1;
    

    }

    I call this function in the http constructor, just before the connect.
    But when I try to download a page from my server I got the following error:
    SSLRead failed: -9842

    The same code works fine on Windows10 without any error.
    Any idea?

    Many thanks in advance,
    i.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pkissel 0
      wrote on last edited by
      #2

      Hi. Having same problem. Did you ever find the reason for the difference between Mac and Windows?
      Thanks!
      Paul

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

        Hi,

        The macOS port doesn't use OpenSSL anymore as the official Apple cryptographic API is provided by the SecureTransport framework.

        IIRC, depending on how the key was generated, the reading might fail. But it should be fixed for either 5.11 or 5.12.

        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