Skip to content

Commit

Permalink
Merge pull request #21663 from sledgehammer999/backport_dont_ignore_s…
Browse files Browse the repository at this point in the history
…sl_errors

Don't ignore SSL errors
  • Loading branch information
sledgehammer999 authored Oct 24, 2024
2 parents 49f57b1 + 2a40774 commit e58b0a6
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 37 deletions.
16 changes: 13 additions & 3 deletions src/base/net/downloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,20 @@ Net::DownloadManager::DownloadManager(QObject *parent)
QStringList errorList;
for (const QSslError &error : errors)
errorList += error.errorString();
LogMsg(tr("Ignoring SSL error, URL: \"%1\", errors: \"%2\"").arg(reply->url().toString(), errorList.join(u". ")), Log::WARNING);

// Ignore all SSL errors
reply->ignoreSslErrors();
QString errorMsg;
if (!Preferences::instance()->isIgnoreSSLErrors())
{
errorMsg = tr("SSL error, URL: \"%1\", errors: \"%2\"");
}
else
{
errorMsg = tr("Ignoring SSL error, URL: \"%1\", errors: \"%2\"");
// Ignore all SSL errors
reply->ignoreSslErrors();
}

LogMsg(errorMsg.arg(reply->url().toString(), errorList.join(u". ")), Log::WARNING);
});

connect(ProxyConfigurationManager::instance(), &ProxyConfigurationManager::proxyConfigurationChanged
Expand Down
13 changes: 13 additions & 0 deletions src/base/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,19 @@ void Preferences::setMarkOfTheWebEnabled(const bool enabled)
setValue(u"Preferences/Advanced/markOfTheWeb"_s, enabled);
}

bool Preferences::isIgnoreSSLErrors() const
{
return value(u"Preferences/Advanced/IgnoreSSLErrors"_s, false);
}

void Preferences::setIgnoreSSLErrors(const bool enabled)
{
if (enabled == isIgnoreSSLErrors())
return;

setValue(u"Preferences/Advanced/IgnoreSSLErrors"_s, enabled);
}

Path Preferences::getPythonExecutablePath() const
{
return value(u"Preferences/Search/pythonExecutablePath"_s, Path());
Expand Down
2 changes: 2 additions & 0 deletions src/base/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ class Preferences final : public QObject
void setTrackerPortForwardingEnabled(bool enabled);
bool isMarkOfTheWebEnabled() const;
void setMarkOfTheWebEnabled(bool enabled);
bool isIgnoreSSLErrors() const;
void setIgnoreSSLErrors(bool enabled);
Path getPythonExecutablePath() const;
void setPythonExecutablePath(const Path &path);
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
Expand Down
7 changes: 7 additions & 0 deletions src/gui/advancedsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ namespace
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
ENABLE_MARK_OF_THE_WEB,
#endif // Q_OS_MACOS || Q_OS_WIN
IGNORE_SSL_ERRORS,
PYTHON_EXECUTABLE_PATH,
START_SESSION_PAUSED,
SESSION_SHUTDOWN_TIMEOUT,
Expand Down Expand Up @@ -332,6 +333,8 @@ void AdvancedSettings::saveAdvancedSettings() const
// Mark-of-the-Web
pref->setMarkOfTheWebEnabled(m_checkBoxMarkOfTheWeb.isChecked());
#endif // Q_OS_MACOS || Q_OS_WIN
// Ignore SSL errors
pref->setIgnoreSSLErrors(m_checkBoxIgnoreSSLErrors.isChecked());
// Python executable path
pref->setPythonExecutablePath(Path(m_pythonExecutablePath.text().trimmed()));
// Start session paused
Expand Down Expand Up @@ -853,6 +856,10 @@ void AdvancedSettings::loadAdvancedSettings()
m_checkBoxMarkOfTheWeb.setChecked(pref->isMarkOfTheWebEnabled());
addRow(ENABLE_MARK_OF_THE_WEB, motwLabel, &m_checkBoxMarkOfTheWeb);
#endif // Q_OS_MACOS || Q_OS_WIN
// Ignore SSL errors
m_checkBoxIgnoreSSLErrors.setChecked(pref->isIgnoreSSLErrors());
m_checkBoxIgnoreSSLErrors.setToolTip(tr("Affects certificate validation and non-torrent protocol activities (e.g. RSS feeds, program updates, torrent files, geoip db, etc)"));
addRow(IGNORE_SSL_ERRORS, tr("Ignore SSL errors"), &m_checkBoxIgnoreSSLErrors);
// Python executable path
m_pythonExecutablePath.setPlaceholderText(tr("(Auto detect if empty)"));
m_pythonExecutablePath.setText(pref->getPythonExecutablePath().toString());
Expand Down
7 changes: 4 additions & 3 deletions src/gui/advancedsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ private slots:
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval, m_spinBoxRequestQueueSize;
QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts,
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxReannounceWhenAddressChanged, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
m_checkBoxTrackerPortForwarding, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers,
m_checkBoxMultiConnectionsPerIp, m_checkBoxValidateHTTPSTrackerCertificate, m_checkBoxSSRFMitigation, m_checkBoxBlockPeersOnPrivilegedPorts, m_checkBoxPieceExtentAffinity,
m_checkBoxSuggestMode, m_checkBoxSpeedWidgetEnabled, m_checkBoxIDNSupport, m_checkBoxConfirmRemoveTrackerFromAllTorrents, m_checkBoxStartSessionPaused;
m_checkBoxTrackerPortForwarding, m_checkBoxIgnoreSSLErrors, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers,
m_checkBoxAnnounceAllTiers, m_checkBoxMultiConnectionsPerIp, m_checkBoxValidateHTTPSTrackerCertificate, m_checkBoxSSRFMitigation, m_checkBoxBlockPeersOnPrivilegedPorts,
m_checkBoxPieceExtentAffinity, m_checkBoxSuggestMode, m_checkBoxSpeedWidgetEnabled, m_checkBoxIDNSupport, m_checkBoxConfirmRemoveTrackerFromAllTorrents,
m_checkBoxStartSessionPaused;
QComboBox m_comboBoxInterface, m_comboBoxInterfaceAddress, m_comboBoxDiskIOReadMode, m_comboBoxDiskIOWriteMode, m_comboBoxUtpMixedMode, m_comboBoxChokingAlgorithm,
m_comboBoxSeedChokingAlgorithm, m_comboBoxResumeDataStorage, m_comboBoxTorrentContentRemoveOption;
QLineEdit m_lineEditAppInstanceName, m_pythonExecutablePath, m_lineEditAnnounceIP, m_lineEditDHTBootstrapNodes;
Expand Down
47 changes: 26 additions & 21 deletions src/webui/api/appcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ void AppController::preferencesAction()
data[u"resolve_peer_countries"_s] = pref->resolvePeerCountries();
// Reannounce to all trackers when ip/port changed
data[u"reannounce_when_address_changed"_s] = session->isReannounceWhenAddressChangedEnabled();
// Embedded tracker
data[u"enable_embedded_tracker"_s] = session->isTrackerEnabled();
data[u"embedded_tracker_port"_s] = pref->getTrackerPort();
data[u"embedded_tracker_port_forwarding"_s] = pref->isTrackerPortForwardingEnabled();
// Mark-of-the-Web
data[u"mark_of_the_web"_s] = pref->isMarkOfTheWebEnabled();
// Ignore SSL errors
data[u"ignore_ssl_errors"_s] = pref->isIgnoreSSLErrors();
// Python executable path
data[u"python_executable_path"_s] = pref->getPythonExecutablePath().toString();

// libtorrent preferences
// Bdecode depth limit
Expand Down Expand Up @@ -436,14 +446,6 @@ void AppController::preferencesAction()
data[u"ssrf_mitigation"_s] = session->isSSRFMitigationEnabled();
// Disallow connection to peers on privileged ports
data[u"block_peers_on_privileged_ports"_s] = session->blockPeersOnPrivilegedPorts();
// Embedded tracker
data[u"enable_embedded_tracker"_s] = session->isTrackerEnabled();
data[u"embedded_tracker_port"_s] = pref->getTrackerPort();
data[u"embedded_tracker_port_forwarding"_s] = pref->isTrackerPortForwardingEnabled();
// Mark-of-the-Web
data[u"mark_of_the_web"_s] = pref->isMarkOfTheWebEnabled();
// Python executable path
data[u"python_executable_path"_s] = pref->getPythonExecutablePath().toString();
// Choking algorithm
data[u"upload_slots_behavior"_s] = static_cast<int>(session->chokingAlgorithm());
// Seed choking algorithm
Expand Down Expand Up @@ -982,6 +984,22 @@ void AppController::setPreferencesAction()
// Reannounce to all trackers when ip/port changed
if (hasKey(u"reannounce_when_address_changed"_s))
session->setReannounceWhenAddressChangedEnabled(it.value().toBool());
// Embedded tracker
if (hasKey(u"embedded_tracker_port"_s))
pref->setTrackerPort(it.value().toInt());
if (hasKey(u"embedded_tracker_port_forwarding"_s))
pref->setTrackerPortForwardingEnabled(it.value().toBool());
if (hasKey(u"enable_embedded_tracker"_s))
session->setTrackerEnabled(it.value().toBool());
// Mark-of-the-Web
if (hasKey(u"mark_of_the_web"_s))
pref->setMarkOfTheWebEnabled(it.value().toBool());
// Ignore SLL errors
if (hasKey(u"ignore_ssl_errors"_s))
pref->setIgnoreSSLErrors(it.value().toBool());
// Python executable path
if (hasKey(u"python_executable_path"_s))
pref->setPythonExecutablePath(Path(it.value().toString()));

// libtorrent preferences
// Bdecode depth limit
Expand Down Expand Up @@ -1076,19 +1094,6 @@ void AppController::setPreferencesAction()
// Disallow connection to peers on privileged ports
if (hasKey(u"block_peers_on_privileged_ports"_s))
session->setBlockPeersOnPrivilegedPorts(it.value().toBool());
// Embedded tracker
if (hasKey(u"embedded_tracker_port"_s))
pref->setTrackerPort(it.value().toInt());
if (hasKey(u"embedded_tracker_port_forwarding"_s))
pref->setTrackerPortForwardingEnabled(it.value().toBool());
if (hasKey(u"enable_embedded_tracker"_s))
session->setTrackerEnabled(it.value().toBool());
// Mark-of-the-Web
if (hasKey(u"mark_of_the_web"_s))
pref->setMarkOfTheWebEnabled(it.value().toBool());
// Python executable path
if (hasKey(u"python_executable_path"_s))
pref->setPythonExecutablePath(Path(it.value().toString()));
// Choking algorithm
if (hasKey(u"upload_slots_behavior"_s))
session->setChokingAlgorithm(static_cast<BitTorrent::ChokingAlgorithm>(it.value().toInt()));
Expand Down
30 changes: 20 additions & 10 deletions src/webui/www/private/views/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,14 @@
<input type="checkbox" id="markOfTheWeb" />
</td>
</tr>
<tr>
<td>
<label for="ignoreSSLErrors">QBT_TR(Ignore SSL errors:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="checkbox" id="ignoreSSLErrors">
</td>
</tr>
<tr>
<td>
<label for="pythonExecutablePath">QBT_TR(Python executable path (may require restart):)QBT_TR[CONTEXT=OptionsDialog]</label>
Expand Down Expand Up @@ -2353,6 +2361,12 @@
$("refreshInterval").setProperty("value", pref.refresh_interval);
$("resolvePeerCountries").setProperty("checked", pref.resolve_peer_countries);
$("reannounceWhenAddressChanged").setProperty("checked", pref.reannounce_when_address_changed);
$("enableEmbeddedTracker").setProperty("checked", pref.enable_embedded_tracker);
$("embeddedTrackerPort").setProperty("value", pref.embedded_tracker_port);
$("embeddedTrackerPortForwarding").setProperty("checked", pref.embedded_tracker_port_forwarding);
$("markOfTheWeb").setProperty("checked", pref.mark_of_the_web);
$("ignoreSSLErrors").setProperty("checked", pref.ignore_ssl_errors);
$("pythonExecutablePath").setProperty("value", pref.python_executable_path);
// libtorrent section
$("bdecodeDepthLimit").setProperty("value", pref.bdecode_depth_limit);
$("bdecodeTokenLimit").setProperty("value", pref.bdecode_token_limit);
Expand Down Expand Up @@ -2386,11 +2400,6 @@
$("validateHTTPSTrackerCertificate").setProperty("checked", pref.validate_https_tracker_certificate);
$("mitigateSSRF").setProperty("checked", pref.ssrf_mitigation);
$("blockPeersOnPrivilegedPorts").setProperty("checked", pref.block_peers_on_privileged_ports);
$("enableEmbeddedTracker").setProperty("checked", pref.enable_embedded_tracker);
$("embeddedTrackerPort").setProperty("value", pref.embedded_tracker_port);
$("embeddedTrackerPortForwarding").setProperty("checked", pref.embedded_tracker_port_forwarding);
$("markOfTheWeb").setProperty("checked", pref.mark_of_the_web);
$("pythonExecutablePath").setProperty("value", pref.python_executable_path);
$("uploadSlotsBehavior").setProperty("value", pref.upload_slots_behavior);
$("uploadChokingAlgorithm").setProperty("value", pref.upload_choking_algorithm);
$("announceAllTrackers").setProperty("checked", pref.announce_to_all_trackers);
Expand Down Expand Up @@ -2802,6 +2811,12 @@
settings["refresh_interval"] = Number($("refreshInterval").getProperty("value"));
settings["resolve_peer_countries"] = $("resolvePeerCountries").getProperty("checked");
settings["reannounce_when_address_changed"] = $("reannounceWhenAddressChanged").getProperty("checked");
settings["enable_embedded_tracker"] = $("enableEmbeddedTracker").getProperty("checked");
settings["embedded_tracker_port"] = Number($("embeddedTrackerPort").getProperty("value"));
settings["embedded_tracker_port_forwarding"] = $("embeddedTrackerPortForwarding").getProperty("checked");
settings["mark_of_the_web"] = $("markOfTheWeb").getProperty("checked");
settings["ignore_ssl_errors"] = $("ignoreSSLErrors").getProperty("checked");
settings["python_executable_path"] = $("pythonExecutablePath").getProperty("value");

// libtorrent section
settings["bdecode_depth_limit"] = Number($("bdecodeDepthLimit").getProperty("value"));
Expand Down Expand Up @@ -2836,11 +2851,6 @@
settings["validate_https_tracker_certificate"] = $("validateHTTPSTrackerCertificate").getProperty("checked");
settings["ssrf_mitigation"] = $("mitigateSSRF").getProperty("checked");
settings["block_peers_on_privileged_ports"] = $("blockPeersOnPrivilegedPorts").getProperty("checked");
settings["enable_embedded_tracker"] = $("enableEmbeddedTracker").getProperty("checked");
settings["embedded_tracker_port"] = Number($("embeddedTrackerPort").getProperty("value"));
settings["embedded_tracker_port_forwarding"] = $("embeddedTrackerPortForwarding").getProperty("checked");
settings["mark_of_the_web"] = $("markOfTheWeb").getProperty("checked");
settings["python_executable_path"] = $("pythonExecutablePath").getProperty("value");
settings["upload_slots_behavior"] = Number($("uploadSlotsBehavior").getProperty("value"));
settings["upload_choking_algorithm"] = Number($("uploadChokingAlgorithm").getProperty("value"));
settings["announce_to_all_trackers"] = $("announceAllTrackers").getProperty("checked");
Expand Down

0 comments on commit e58b0a6

Please sign in to comment.