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.


Log in to reply
 

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