PDA

View Full Version : Ignore SSL Errors



Oliver76
27th April 2012, 15:16
Hi there,

I'm quite new to QT and I cannot find a working example, just suggestions like function X, but I don't know how. I need to get some files over https. My code without ssl is:



http = new QHttp(this);
http->setHost("search.for.updates.com");
connect(http, SIGNAL(done(bool)), this, SLOT(checkUpdate()));
http->get("/latest");


This works. :)
Now I need SSL, but my test certificate is not validated (StartSSL, Class 1).



http = new QHttp(this);
http->setHost("search.for.updates.com", QHttp::ConnectionModeHttps);
connect(http, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(handleSslErrors(const QList<QSslError> & errors)));
connect(http, SIGNAL(done(bool)), this, SLOT(checkUpdate()));
http->get("/latest");


How must the handleSslErrors Function look like? I tried this and other variations, but it just don't work.



void MainWindow::handleSslErrors(const QList<QSslError> & errors) {
foreach (QSslError error, errors)
{
error->ignoreSslErrors();
}
}


Can anybody give me a hint? Thanks in advance.

Added after 11 minutes:

Ok I found out, this works, but the response is still empty:



void MainWindow::handleSslErrors(const QList<QSslError> & errors) {
http->ignoreSslErrors();
}