mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Introducing SSL Exceptions Manager + option to ignore all ssl warnings
This commit is contained in:
parent
89240d4692
commit
9b232af3ab
@ -24,6 +24,7 @@
|
||||
NetworkManager::NetworkManager(QupZilla* mainClass, QObject *parent) :
|
||||
NetworkManagerProxy(mainClass, parent)
|
||||
,p_QupZilla(mainClass)
|
||||
,m_ignoreAllWarnings(false)
|
||||
{
|
||||
connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authentication(QNetworkReply*, QAuthenticator* )));
|
||||
connect(this, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(sslError(QNetworkReply*,QList<QSslError>)));
|
||||
@ -42,11 +43,16 @@ void NetworkManager::loadSettings()
|
||||
m_diskCache->setMaximumCacheSize(settings.value("MaximumCacheSize",50).toInt() * 1024*1024); //MegaBytes
|
||||
setCache(m_diskCache);
|
||||
}
|
||||
m_ignoreAllWarnings = settings.value("IgnoreAllSSLWarnings", false).toBool();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void NetworkManager::sslError(QNetworkReply *reply, QList<QSslError> errors)
|
||||
{
|
||||
if (m_ignoreAllWarnings) {
|
||||
reply->ignoreSslErrors(errors);
|
||||
return;
|
||||
}
|
||||
QString title = tr("SSL Certificate Error!");
|
||||
QString text1 = tr("The page you trying to access has following errors in SSL Certificate:");
|
||||
|
||||
|
@ -63,6 +63,7 @@ private:
|
||||
QList<QSslCertificate> m_certExceptions;
|
||||
QNetworkDiskCache* m_diskCache;
|
||||
|
||||
bool m_ignoreAllWarnings;
|
||||
};
|
||||
|
||||
#endif // NETWORKMANAGER_H
|
||||
|
@ -26,13 +26,69 @@ SSLManager::SSLManager(QWidget *parent) :
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(this);
|
||||
QList<QSslCertificate> certs = mApp->networkManager()->getCertExceptions();
|
||||
foreach (QSslCertificate cert, certs) {
|
||||
m_certs = mApp->networkManager()->getCertExceptions();
|
||||
foreach (QSslCertificate cert, m_certs) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->list);
|
||||
item->setText(cert.serialNumber());
|
||||
item->setData(0, certs.indexOf(cert));
|
||||
item->setText( cert.subjectInfo(QSslCertificate::Organization) + " " + cert.subjectInfo(QSslCertificate::CommonName) );
|
||||
item->setWhatsThis(QString::number(m_certs.indexOf(cert)));
|
||||
ui->list->addItem(item);
|
||||
}
|
||||
|
||||
connect(ui->list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showCertificateInfo()));
|
||||
connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(showCertificateInfo()));
|
||||
connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCertificate()));
|
||||
connect(ui->ignoreAll, SIGNAL(clicked(bool)), this, SLOT(ignoreAll(bool)));
|
||||
|
||||
QSettings settings(mApp->getActiveProfil()+"settings.ini", QSettings::IniFormat);
|
||||
settings.beginGroup("Web-Browser-Settings");
|
||||
ui->ignoreAll->setChecked( settings.value("IgnoreAllSSLWarnings", false).toBool() );
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void SSLManager::showCertificateInfo()
|
||||
{
|
||||
QListWidgetItem* item = ui->list->currentItem();
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
QSslCertificate cert = m_certs.at(item->whatsThis().toInt());
|
||||
QStringList actions;
|
||||
actions.append(tr("<b>Organization: </b>") + cert.subjectInfo(QSslCertificate::Organization));
|
||||
actions.append(tr("<b>Domain Name: </b>") + cert.subjectInfo(QSslCertificate::CommonName));
|
||||
actions.append(tr("<b>Locality Name: </b>") + cert.subjectInfo(QSslCertificate::LocalityName));
|
||||
actions.append(tr("<b>Country Name: </b>") + cert.subjectInfo(QSslCertificate::CountryName));
|
||||
actions.append(tr("<b>Verified by: </b>") + cert.subjectInfo(QSslCertificate::OrganizationalUnitName));
|
||||
actions.append(tr("<b>Expiration Date: </b>") + cert.expiryDate().toString("hh:mm:ss dddd d. MMMM yyyy"));
|
||||
|
||||
QString message = QString(QLatin1String("<ul><li>%3</li></ul>")).arg(actions.join(QLatin1String("</li><li>")));
|
||||
|
||||
QMessageBox mes;
|
||||
mes.setIcon(QMessageBox::Information);
|
||||
mes.setWindowTitle(tr("SSL Certificate Informations"));
|
||||
mes.setText(message);
|
||||
mes.setDetailedText(cert.toPem());
|
||||
mes.exec();
|
||||
}
|
||||
|
||||
void SSLManager::deleteCertificate()
|
||||
{
|
||||
QListWidgetItem* item = ui->list->currentItem();
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
QSslCertificate cert = m_certs.at(item->whatsThis().toInt());
|
||||
m_certs.removeOne(cert);
|
||||
mApp->networkManager()->setCertExceptions(m_certs);
|
||||
delete item;
|
||||
}
|
||||
|
||||
void SSLManager::ignoreAll(bool state)
|
||||
{
|
||||
QSettings settings(mApp->getActiveProfil()+"settings.ini", QSettings::IniFormat);
|
||||
settings.beginGroup("Web-Browser-Settings");
|
||||
settings.setValue("IgnoreAllSSLWarnings", state);
|
||||
settings.endGroup();
|
||||
mApp->networkManager()->loadSettings();
|
||||
}
|
||||
|
||||
SSLManager::~SSLManager()
|
||||
|
@ -15,12 +15,15 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
|
||||
|
||||
#ifndef SSLMANAGER_H
|
||||
#define SSLMANAGER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QSslCertificate>
|
||||
#include <QDateTime>
|
||||
#include <QSettings>
|
||||
|
||||
namespace Ui {
|
||||
class SSLManager;
|
||||
@ -34,8 +37,14 @@ public:
|
||||
explicit SSLManager(QWidget *parent = 0);
|
||||
~SSLManager();
|
||||
|
||||
private slots:
|
||||
void showCertificateInfo();
|
||||
void deleteCertificate();
|
||||
void ignoreAll(bool state);
|
||||
|
||||
private:
|
||||
Ui::SSLManager *ui;
|
||||
QList<QSslCertificate> m_certs;
|
||||
};
|
||||
|
||||
#endif // SSLMANAGER_H
|
||||
|
Loading…
Reference in New Issue
Block a user