MAC osX SSL issue SSLRead failed: -9842



  • 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.



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


  • Lifetime Qt Champion

    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.


Log in to reply
 

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