1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

Implement permanent exceptions for SSL certificates, enable only for this session

This commit is contained in:
Javier Llorente 2023-04-20 22:57:58 +02:00 committed by Juraj Oravec
parent 767c1406e4
commit 34e7eb1713
3 changed files with 17 additions and 4 deletions

View File

@ -78,8 +78,10 @@ bool NetworkManager::certificateError(const QWebEngineCertificateError &error, Q
return false;
}
if (m_ignoredSslErrors.contains(host) && m_ignoredSslErrors.value(host) == error.error())
if ((m_ignoredSslErrors.contains(host) && m_ignoredSslErrors.value(host) == error.error())
|| m_ignoredSslHosts.contains(host)) {
return true;
}
QString title = tr("SSL Certificate Error!");
QString text1 = tr("The page you are trying to access has the following errors in the SSL certificate:");
@ -93,7 +95,9 @@ bool NetworkManager::certificateError(const QWebEngineCertificateError &error, Q
switch (dialog.result()) {
case SslErrorDialog::Yes:
// TODO: Permanent exceptions
m_ignoredSslHosts.append(host);
return true;
case SslErrorDialog::OnlyForThisSession:
m_ignoredSslErrors[host] = error.error();
return true;
@ -288,10 +292,19 @@ void NetworkManager::loadSettings()
}
m_urlInterceptor->loadSettings();
settings.beginGroup("Web-Browser-Settings");
m_ignoredSslHosts = settings.value("IgnoredSslHosts", QStringList()).toStringList();
settings.endGroup();
}
void NetworkManager::shutdown()
{
Settings settings;
settings.beginGroup("Web-Browser-Settings");
settings.setValue("IgnoredSslHosts", m_ignoredSslHosts);
settings.endGroup();
mApp->webProfile()->setUrlRequestInterceptor(nullptr);
}

View File

@ -58,6 +58,7 @@ private:
ExtensionSchemeManager *m_extensionScheme;
QHash<QString, QWebEngineCertificateError::Error> m_ignoredSslErrors;
QHash<QString, QWebEngineCertificateError::Error> m_rejectedSslErrors;
QStringList m_ignoredSslHosts;
};
#endif // NETWORKMANAGER_H

View File

@ -28,8 +28,7 @@ SslErrorDialog::SslErrorDialog(QWidget* parent)
{
ui->setupUi(this);
ui->icon->setPixmap(IconProvider::standardIcon(QStyle::SP_MessageBoxCritical).pixmap(52));
// Disabled until there is reliable way to save certificate error
//ui->buttonBox->addButton(tr("Only for this session"), QDialogButtonBox::ApplyRole);
ui->buttonBox->addButton(tr("Only for this session"), QDialogButtonBox::ApplyRole);
ui->buttonBox->button(QDialogButtonBox::No)->setFocus();
connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &SslErrorDialog::buttonClicked);