Created
April 30, 2012 14:16
-
-
Save gokmen/2558692 to your computer and use it in GitHub Desktop.
If you have trouble with QWebView and SSL errors you can ignore SSL errors to render page correctly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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
is it works for some website like google.com ? ( they're force to use HTTPS )