Skip to content

Instantly share code, notes, and snippets.

@matiasinsaurralde
Forked from gokmen/main.cpp
Last active August 29, 2015 14:22
Show Gist options
  • Save matiasinsaurralde/4f42e3f8bbab3c90d40d to your computer and use it in GitHub Desktop.
Save matiasinsaurralde/4f42e3f8bbab3c90d40d to your computer and use it in GitHub Desktop.
#include <QDebug>
#include <QWidget>
#include <QNetworkReply>
#include <QSslConfiguration>
App::App(QWidget *parent) :
QWidget(parent),
ui(new Ui::App)
{
ui->setupUi(this);
QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
QList<QSslCertificate> ca_list = sslCfg.caCertificates();
QList<QSslCertificate> 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<QSslError> & )),
this,
SLOT(sslErrorHandler(QNetworkReply*, const QList<QSslError> & )));
}
void App::sslErrorHandler(QNetworkReply* qnr, const QList<QSslError> & errlist)
{
#if DEBUG_ENABLED
qDebug() << "---frmBuyIt::sslErrorHandler: ";
// show list of all ssl errors
foreach (QSslError err, errlist)
qDebug() << "ssl error: " << err;
#endif
qnr->ignoreSslErrors();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment