Results 1 to 3 of 3

Thread: HTTPS download failed - Qt 4.5.2

  1. #1
    Join Date
    Aug 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default HTTPS download failed - Qt 4.5.2

    I am using Qt 4.5.2 now and am having some problem downloading date via HTTPS.
    Here are what I do:

    ...
    class A
    {
    static QSslConfiguration m_sconfig;
    }

    A::Start()
    {
    m_sconfig.setProtocol( QSsl::AnyProtocol );
    QSslConfiguration::setDefaultConfiguration(m_sconf ig);
    ...
    connect(&m_http, SIGNAL(readyRead(const QHttpResponseHeader &)), this, SLOT(readData(const QHttpResponseHeader &)));
    connect(&m_http, SIGNAL(requestFinished(int, bool)), this, SLOT(finished(int, bool)));
    connect(&m_http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), this, SLOT(readResponseHeader(const QHttpResponseHeader &)));

    connect(&m_http, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(handleSslErrors(const QList<QSslError> &)));

    QHttp::ConnectionMode mode = url->scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;

    // This works fine.
    m_http.setHost("MyHost", mode, url->port() == -1 ? 0 : url->port());


    // This results in a "HTTP request failed" error.
    _id = m_http.get(""Relative_Path_on_Server");

    ...
    }

    The readResponseHeader(const QHttpResponseHeader &responseHeader) function was never called. So it seemed the HTTPS request was never sent out to the server.

    If I switched to HTTP, all worked fine.
    What am I missing?
    I think this worked with Qt 4.4.3 as far as I remember.
    Thanks in advance for any help.

    By the way, I am using the commercial version of Qt and I was told that the OpenSsl support is built in.
    And I debugged the Qt source and got the following error:

    "Invalid or empty cipher list (error:1410D0B9:SSL routines:SSL_CTX_set_cipher_list:no cipher match)"
    _____
    Danny
    Last edited by dannyt; 8th August 2009 at 08:10. Reason: more information

  2. #2
    Join Date
    Aug 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: HTTPS download failed - Qt 4.5.2

    I found it hard to get it working with the QHttp class and reimplemented this with the newer QNetworkManager. It is now working.
    I don't know why TrollTech can't just make it easier to use like creating a QHttps class.

  3. #3
    Join Date
    Jul 2009
    Posts
    26
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows

    Default Re: HTTPS download failed - Qt 4.5.2

    Hi,

    Maybe a bit too late, however it might help someone in the future.
    I had the same error ("HTTP request failed") and what worked for me was to connect to sslErrors signal and invoke QHttp::ignoreSslErrors() there. This is necessary if, for example, you connect with https to a server with self signed certificate. Of course there is a precaution needed in it, as stated in http://doc.trolltech.com/4.6/qsslsoc...gnoreSslErrors .

    Regards,
    Krzysztof.

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.