Results 1 to 10 of 10

Thread: QNetworkAccessManager: "SSL handshake failed"

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    kleag Guest

    Question QNetworkAccessManager: "SSL handshake failed"

    Hello,

    I'm trying to access to a SOAP web service protected by certificate (the server one is auto-signed, the client one should be presented).
    I'm using Qt4.5 from qt-copy (in kde) under GNU/Linux but I had the same problem with Qt4.4.x

    I'm using the following code:
    Qt Code:
    1. qDebug() << "setting up SSL configuration: " << m_sslKeyFile;
    2. QSslConfiguration sslConfiguration = request.sslConfiguration();
    3. QFile sslCertificateFile(m_sslKeyFile);
    4. if (sslCertificateFile.open(QIODevice::ReadOnly))
    5. {
    6. QSslCertificate certif(&sslCertificateFile);
    7. sslCertificateFile.close();
    8. if (certif.isNull())
    9. {
    10. qDebug() << "Failed to load certificate";
    11. }
    12. qDebug() << "certif version=" << certif.version() << ", serial=" << certif.serialNumber()
    13. << ", issuer=" << certif.issuerInfo(QSslCertificate::Organization)
    14. << " and subject=" << certif.subjectInfo(QSslCertificate::CommonName);
    15. sslConfiguration.setLocalCertificate(certif);
    16. sslCertificateFile.close();
    17. sslCertificateFile.open(QIODevice::ReadOnly);
    18. QSslKey key(&sslCertificateFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
    19. qDebug() << "key isNull ? " << key.isNull();
    20. sslConfiguration.setPrivateKey(key);
    21. sslConfiguration.setProtocol(QSsl::SslV2);
    22. sslConfiguration.setPeerVerifyMode(QSslSocket::QueryPeer);
    23. request.setSslConfiguration(sslConfiguration);
    24. }
    25. ...
    26. qDebug() << "send post";
    27. m_networkReply = m_networkAccessManager->post(request, m_tempFile); // m_networkAccessManager est QNetworkAccessManager
    28. ...
    29. void QSoapServiceClient::slotNetworkReplyError(QNetworkReply::NetworkError)
    30. {
    31. qDebug() << "QSoapServiceClient::slotNetworkReplyError: " << m_networkReply->errorString();
    32. m_answer = "";
    33. }
    To copy to clipboard, switch view to plain text mode 

    And I obtain at runtime:
    Qt Code:
    1. setting up SSL configuration: "/path/to/pem/file"
    2. certif version= "" , serial= "" , issuer= "xxx" and subject= "yyy"
    3. key isNull ? false
    4. send post
    5. connecting reply signals
    6. sent
    7. QSoapServiceClient::slotNetworkReplyError: "SSL handshake failed"
    To copy to clipboard, switch view to plain text mode 

    Note that by using a QProcess launching curl with options -k and -E, it works... Thus the certificate is OK. It's really my code which is bad but I cannot see where...

    Any idea ?
    Last edited by jacek; 13th February 2009 at 23:38. Reason: wrapped too long line

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.