Skip to content

Commit 863ff3e

Browse files
Don't ignore SSL errors
1 parent 1c43286 commit 863ff3e

5 files changed

+39
-6
lines changed

src/base/net/downloadmanager.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,20 @@ Net::DownloadManager::DownloadManager(QObject *parent)
148148
QStringList errorList;
149149
for (const QSslError &error : errors)
150150
errorList += error.errorString();
151-
LogMsg(tr("Ignoring SSL error, URL: \"%1\", errors: \"%2\"").arg(reply->url().toString(), errorList.join(u". ")), Log::WARNING);
152151

153-
// Ignore all SSL errors
154-
reply->ignoreSslErrors();
152+
QString errorMsg;
153+
if (Preferences::instance()->isValidateTLSCertificate())
154+
{
155+
errorMsg = tr("SSL error, URL: \"%1\", errors: \"%2\"");
156+
}
157+
else
158+
{
159+
errorMsg = tr("Ignoring SSL error, URL: \"%1\", errors: \"%2\"");
160+
// Ignore all SSL errors
161+
reply->ignoreSslErrors();
162+
}
163+
164+
LogMsg(errorMsg.arg(reply->url().toString(), errorList.join(u". ")), Log::WARNING);
155165
});
156166

157167
connect(ProxyConfigurationManager::instance(), &ProxyConfigurationManager::proxyConfigurationChanged

src/base/preferences.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,19 @@ void Preferences::setMarkOfTheWebEnabled(const bool enabled)
13301330
setValue(u"Preferences/Advanced/markOfTheWeb"_s, enabled);
13311331
}
13321332

1333+
bool Preferences::isValidateTLSCertificate() const
1334+
{
1335+
return value(u"Preferences/Advanced/ValidateTLSCertificate"_s, true);
1336+
}
1337+
1338+
void Preferences::setValidateTLSCertificate(bool enabled)
1339+
{
1340+
if (enabled == isValidateTLSCertificate())
1341+
return;
1342+
1343+
setValue(u"Preferences/Advanced/ValidateTLSCertificate"_s, enabled);
1344+
}
1345+
13331346
Path Preferences::getPythonExecutablePath() const
13341347
{
13351348
return value(u"Preferences/Search/pythonExecutablePath"_s, Path());

src/base/preferences.h

+2
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ class Preferences final : public QObject
293293
void setTrackerPortForwardingEnabled(bool enabled);
294294
bool isMarkOfTheWebEnabled() const;
295295
void setMarkOfTheWebEnabled(bool enabled);
296+
bool isValidateTLSCertificate() const;
297+
void setValidateTLSCertificate(bool enabled);
296298
Path getPythonExecutablePath() const;
297299
void setPythonExecutablePath(const Path &path);
298300
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)

src/gui/advancedsettings.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ namespace
106106
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
107107
ENABLE_MARK_OF_THE_WEB,
108108
#endif // Q_OS_MACOS || Q_OS_WIN
109+
VALIDATE_TLS_CERTIFICATE,
109110
PYTHON_EXECUTABLE_PATH,
110111
START_SESSION_PAUSED,
111112
SESSION_SHUTDOWN_TIMEOUT,
@@ -335,6 +336,8 @@ void AdvancedSettings::saveAdvancedSettings() const
335336
// Mark-of-the-Web
336337
pref->setMarkOfTheWebEnabled(m_checkBoxMarkOfTheWeb.isChecked());
337338
#endif // Q_OS_MACOS || Q_OS_WIN
339+
// Validate TLS certificate
340+
pref->setValidateTLSCertificate(m_checkBoxValidateTLSCertificate.isChecked());
338341
// Python executable path
339342
pref->setPythonExecutablePath(Path(m_pythonExecutablePath.text().trimmed()));
340343
// Start session paused
@@ -863,6 +866,10 @@ void AdvancedSettings::loadAdvancedSettings()
863866
m_checkBoxMarkOfTheWeb.setChecked(pref->isMarkOfTheWebEnabled());
864867
addRow(ENABLE_MARK_OF_THE_WEB, motwLabel, &m_checkBoxMarkOfTheWeb);
865868
#endif // Q_OS_MACOS || Q_OS_WIN
869+
// Validate TLS certificate
870+
m_checkBoxValidateTLSCertificate.setChecked(pref->isValidateTLSCertificate());
871+
m_checkBoxValidateTLSCertificate.setToolTip(tr("Validate TLS certificate for HTTPS URLs (e.g. RSS feeds, program updates, torrent files, geoip db, etc)"));
872+
addRow(VALIDATE_TLS_CERTIFICATE, tr("Validate TLS certificates"), &m_checkBoxValidateTLSCertificate);
866873
// Python executable path
867874
m_pythonExecutablePath.setPlaceholderText(tr("(Auto detect if empty)"));
868875
m_pythonExecutablePath.setText(pref->getPythonExecutablePath().toString());

src/gui/advancedsettings.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ private slots:
7777
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval, m_spinBoxRequestQueueSize;
7878
QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts,
7979
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxReannounceWhenAddressChanged, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
80-
m_checkBoxTrackerPortForwarding, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers,
81-
m_checkBoxMultiConnectionsPerIp, m_checkBoxValidateHTTPSTrackerCertificate, m_checkBoxSSRFMitigation, m_checkBoxBlockPeersOnPrivilegedPorts, m_checkBoxPieceExtentAffinity,
82-
m_checkBoxSuggestMode, m_checkBoxSpeedWidgetEnabled, m_checkBoxIDNSupport, m_checkBoxConfirmRemoveTrackerFromAllTorrents, m_checkBoxStartSessionPaused;
80+
m_checkBoxTrackerPortForwarding, m_checkBoxValidateTLSCertificate, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers,
81+
m_checkBoxAnnounceAllTiers, m_checkBoxMultiConnectionsPerIp, m_checkBoxValidateHTTPSTrackerCertificate, m_checkBoxSSRFMitigation, m_checkBoxBlockPeersOnPrivilegedPorts,
82+
m_checkBoxPieceExtentAffinity, m_checkBoxSuggestMode, m_checkBoxSpeedWidgetEnabled, m_checkBoxIDNSupport, m_checkBoxConfirmRemoveTrackerFromAllTorrents,
83+
m_checkBoxStartSessionPaused;
8384
QComboBox m_comboBoxInterface, m_comboBoxInterfaceAddress, m_comboBoxDiskIOReadMode, m_comboBoxDiskIOWriteMode, m_comboBoxUtpMixedMode, m_comboBoxChokingAlgorithm,
8485
m_comboBoxSeedChokingAlgorithm, m_comboBoxResumeDataStorage, m_comboBoxTorrentContentRemoveOption;
8586
QLineEdit m_lineEditAppInstanceName, m_pythonExecutablePath, m_lineEditAnnounceIP, m_lineEditDHTBootstrapNodes;

0 commit comments

Comments
 (0)