Skip to content

Commit

Permalink
feat(core): add option to ignore SSL errors (#1521)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeckerSU committed Aug 6, 2023
1 parent 94247fd commit 9eb6169
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/libs/core/application.cpp
Expand Up @@ -66,6 +66,14 @@ Application::Application(QObject *parent)
m_fileManager = new FileManager(this);
m_httpServer = new HttpServer(this);

connect(m_networkManager, &QNetworkAccessManager::sslErrors, this, [this](QNetworkReply *reply, const QList<QSslError> &errors)
{
if (m_settings->isIgnoreSSLErrorsEnabled) {
// Ignore all SSL errors
reply->ignoreSslErrors();
}
});

// Extractor setup
m_extractorThread = new QThread(this);
m_extractor = new Extractor();
Expand Down Expand Up @@ -271,11 +279,13 @@ void Application::applySettings()

QNetworkProxy::setApplicationProxy(proxy);

// Force NM to pick up changes.
m_networkManager->clearAccessCache();
break;
}
}

// Force NM to pick up changes.
m_networkManager->clearAccessCache();

}

QString Application::userAgent()
Expand Down
2 changes: 2 additions & 0 deletions src/libs/core/settings.cpp
Expand Up @@ -181,6 +181,7 @@ void Settings::load()
proxyAuthenticate = settings->value(QStringLiteral("authenticate"), false).toBool();
proxyUserName = settings->value(QStringLiteral("username")).toString();
proxyPassword = settings->value(QStringLiteral("password")).toString();
isIgnoreSSLErrorsEnabled = settings->value(QStringLiteral("ignore_ssl_errors"), false).toBool();
settings->endGroup();

settings->beginGroup(GroupDocsets);
Expand Down Expand Up @@ -268,6 +269,7 @@ void Settings::save()
settings->setValue(QStringLiteral("authenticate"), proxyAuthenticate);
settings->setValue(QStringLiteral("username"), proxyUserName);
settings->setValue(QStringLiteral("password"), proxyPassword);
settings->setValue(QStringLiteral("ignore_ssl_errors"), isIgnoreSSLErrorsEnabled);
settings->endGroup();

settings->beginGroup(GroupDocsets);
Expand Down
1 change: 1 addition & 0 deletions src/libs/core/settings.h
Expand Up @@ -99,6 +99,7 @@ class Settings final : public QObject
Socks5 = 4
};
Q_ENUM(ProxyType)
bool isIgnoreSSLErrorsEnabled;

// Internal
// --------
Expand Down
1 change: 1 addition & 0 deletions src/libs/ui/docsetsdialog.cpp
Expand Up @@ -675,6 +675,7 @@ bool DocsetsDialog::updatesAvailable() const
QNetworkReply *DocsetsDialog::download(const QUrl &url)
{
QNetworkReply *reply = m_application->download(url);

connect(reply, &QNetworkReply::downloadProgress, this, &DocsetsDialog::downloadProgress);
connect(reply, &QNetworkReply::finished, this, &DocsetsDialog::downloadCompleted);
m_replies.append(reply);
Expand Down
4 changes: 4 additions & 0 deletions src/libs/ui/settingsdialog.cpp
Expand Up @@ -255,6 +255,8 @@ void SettingsDialog::loadSettings()
ui->proxyRequiresAuthCheckBox->setChecked(settings->proxyAuthenticate);
ui->proxyUsernameEdit->setText(settings->proxyUserName);
ui->proxyPasswordEdit->setText(settings->proxyPassword);

ui->ignoreSSLErrorsCheckBox->setChecked(settings->isIgnoreSSLErrorsEnabled);
}

void SettingsDialog::saveSettings()
Expand Down Expand Up @@ -330,5 +332,7 @@ void SettingsDialog::saveSettings()
settings->proxyUserName = ui->proxyUsernameEdit->text();
settings->proxyPassword = ui->proxyPasswordEdit->text();

settings->isIgnoreSSLErrorsEnabled = ui->ignoreSSLErrorsCheckBox->isChecked();

settings->save();
}
16 changes: 16 additions & 0 deletions src/libs/ui/settingsdialog.ui
Expand Up @@ -745,6 +745,22 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Security</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QCheckBox" name="ignoreSSLErrorsCheckBox">
<property name="text">
<string>Ignore SSL errors</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
Expand Down

0 comments on commit 9eb6169

Please sign in to comment.