qthttpsopensslqwebviewqt5.5

'https' link is not loading in qwebview in qt creator


I am completely new to Qt and using Qt 5.5.1 version. I need to load an https link in my QWebview widget. But it is not loading. I tried with a different 'https' link address. Some will load, but some others will fail to get load. I googled the issue and found that it is due to an SSL error. If then how I am supposed to rectify this using OpenSSL. I am using Ubuntu 16. Can someone share any sample codes in Qt5.5.1?


Solution

  • You can use QNetworkAccessManager to ignore the SSL errors, something like this:

    QNetworkAccessManager * nwAccessMgr = new QNetworkAccessManager();
    QObject::connect
    (
        nwAccessMgr, 
        &QNetworkAccessManager::sslErrors,
        [](QNetworkReply * reply, const QList<QSslError> & errors)
        {
            reply->ignoreSslErrors()
        }
    );
    view->page()->setNetworkAccessManager(nwAccessMgr);
    

    PS: The added code snippet isn't compiled, so may have minor syntax errors.