Results 1 to 2 of 2

Thread: QWebView: Problem ignoring certificates - ignoreSslErrors seems to have no effect

  1. #1
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWebView: Problem ignoring certificates - ignoreSslErrors seems to have no effect

    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. 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);
    }
    ui.MyQWebView->load(qnr);
    ui.MyQWebView->show();
    }

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

    qnr->ignoreSslErrors();
    }
    Last edited by paulh; 3rd October 2009 at 23:47. Reason: more descriptive title

  2. #2
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView: Problem ignoring certificates - ignoreSslErrors seems to have no effect

    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.

Similar Threads

  1. SSL handshaking without certificates
    By palas in forum Qt Programming
    Replies: 6
    Last Post: 5th August 2008, 22:46
  2. Ignoring scaling graphics view/scale
    By maverick_pol in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 17:44
  3. Ignoring zoomin/zoom out in the GraphicsView
    By maverick_pol in forum Qt Programming
    Replies: 5
    Last Post: 20th July 2007, 06:42
  4. Qt 4.2.3 Configure Issue...
    By amcdaniel in forum Installation and Deployment
    Replies: 4
    Last Post: 13th May 2007, 12:02
  5. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23

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.