How to load an url of self certified https nodejs server inside QWebView

147 Views Asked by At
  1. Running nodejs https local server with self certified key for testing.
  2. Load https://localhost:8888/index.html inside QWebView of QT Application.

QWebView shows no content.

1

There are 1 best solutions below

0
On

Thanks to gokmen.

Following code ignores the ssl errors. We can use this code just for testing.

https://gist.github.com/gokmen/2558692

App::App(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::App)
{
    ui->setupUi(this);

    QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
    QList ca_list = sslCfg.caCertificates();
    QList ca_new = QSslCertificate::fromData("CaCertificates");
    ca_list += ca_new;

    sslCfg.setCaCertificates(ca_list);
    sslCfg.setProtocol(QSsl::AnyProtocol);
    QSslConfiguration::setDefaultConfiguration(sslCfg);

    connect(ui->webView->page()->networkAccessManager(),
            SIGNAL(sslErrors(QNetworkReply*, const QList & )),
            this,
            SLOT(sslErrorHandler(QNetworkReply*, const QList & )));
}

void App::sslErrorHandler(QNetworkReply* qnr, const QList & errlist)
{
  #if DEBUG_ENABLED
  qDebug() ignoreSslErrors();
}