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->setHost("search.for.updates.com");
connect(http, SIGNAL(done(bool)), this, SLOT(checkUpdate()));
http->get("/latest");
http = new QHttp(this);
http->setHost("search.for.updates.com");
connect(http, SIGNAL(done(bool)), this, SLOT(checkUpdate()));
http->get("/latest");
To copy to clipboard, switch view to plain text mode
This works.
Now I need SSL, but my test certificate is not validated (StartSSL, Class 1).
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");
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");
To copy to clipboard, switch view to plain text mode
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();
}
}
void MainWindow::handleSslErrors(const QList<QSslError> & errors) {
foreach (QSslError error, errors)
{
error->ignoreSslErrors();
}
}
To copy to clipboard, switch view to plain text mode
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();
}
void MainWindow::handleSslErrors(const QList<QSslError> & errors) {
http->ignoreSslErrors();
}
To copy to clipboard, switch view to plain text mode
Bookmarks