PDA

View Full Version : HTTPS download failed - Qt 4.5.2



dannyt
8th August 2009, 04:02
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

dannyt
17th August 2009, 17:57
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.

Krzysztow
27th September 2010, 00:36
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/qsslsocket.html#ignoreSslErrors .

Regards,
Krzysztof.