View Full Version : QWebView: Problem ignoring certificates - ignoreSslErrors seems to have no effect

3rd October 2009, 22:48
I am trying to load a web page in QWebView and using ignoreSslErrors as described in Qt documentation to insure the web page is loaded regardless of any issues with the certificate. The essential code is pasted below. When this code is used to access a website with a trusted certificate installed, the web page loads. When the website has a self signed certficate, a "The certificate is self-signed, and untrusted" is passed to the sslErrorHandler below where in the ignoreSslErrors slot is called which is supposed to allow the web page to load if I understand correctly. The web page unfortunately does not load. :confused: I also tried such things as connecting sslErrors directly to ignoreSslErrors to no avail. If someone could tell me what I am missing, I would really appreciate it. Thank you.

void QMyApp::loadWebPage()

QNetworkAccessManager *manager = new QNetworkAccessManager(this);

if(!connect(manager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )),
this, SLOT(sslErrorHandler(QNetworkReply*, const QList<QSslError> & ))))
addMessage("Unable to connect sslErrors signal.", MSG_ERROR);


QUrl qurl("https://mywebsite.org");
bool v = qurl.isValid();
QNetworkRequest qnr(qurl);
QNetworkReply *r = manager->get(qnr);
//connect(r, SIGNAL(sslErrors(const QList &)),
//r, SLOT(ignoreSslErrors()));

if(!connect(r, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(slotError(QNetworkReply::NetworkError))))
addMessage("Unable to connect error signal.", MSG_ERROR);

void QMyApp::sslErrorHandler(QNetworkReply* qnr, const QList<QSslError> & sslErrs)
foreach(QSslError err, sslErrs)
addMessage(err.errorString(), MSG_WARNING);


5th October 2009, 17:40
I still don't understand why the above doesn't work. I was able to work around it however, by first loading the URL into the main frame of a QWebPage, and then connecting the sslErrors signal from the QWebPage::networkAccessManager() to the same sslErrorHandler defined above. Then I set the page using QWebView::setPage. With this, the page loads successfully even though the certificate is self signed.