Add HTTPS tracker certificate validation option

This commit adds a new libtorrent setting to validate HTTPS tracker
certificates. When enabled, libtorrent will validate the certificate
of HTTPS trackers against the system's certificate store. This option
is only enabled on libtorrent versions >= 1.2.6 and on non-Windows
systems, as OpenSSL does not use the system's certificate store on
Windows.
This commit is contained in:
NotTsunami 2020-04-22 15:50:13 -04:00
parent 8e553adc92
commit cc1ebbf379
6 changed files with 55 additions and 1 deletions

View file

@ -105,6 +105,9 @@ enum AdvSettingsRows
OUTGOING_PORT_MAX,
UTP_MIX_MODE,
MULTI_CONNECTIONS_PER_IP,
#ifdef HAS_HTTPS_TRACKER_VALIDATION
VALIDATE_HTTPS_TRACKER_CERTIFICATE,
#endif
// embedded tracker
TRACKER_STATUS,
TRACKER_PORT,
@ -209,6 +212,10 @@ void AdvancedSettings::saveAdvancedSettings()
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(m_comboBoxUtpMixedMode.currentIndex()));
// multiple connections per IP
session->setMultiConnectionsPerIpEnabled(m_checkBoxMultiConnectionsPerIp.isChecked());
#ifdef HAS_HTTPS_TRACKER_VALIDATION
// Validate HTTPS tracker certificate
session->setValidateHTTPSTrackerCertificate(m_checkBoxValidateHTTPSTrackerCertificate.isChecked());
#endif
// Recheck torrents on completion
pref->recheckTorrentsOnCompletion(m_checkBoxRecheckCompleted.isChecked());
// Transfer list refresh interval
@ -485,6 +492,13 @@ void AdvancedSettings::loadAdvancedSettings()
// multiple connections per IP
m_checkBoxMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled());
addRow(MULTI_CONNECTIONS_PER_IP, tr("Allow multiple connections from the same IP address"), &m_checkBoxMultiConnectionsPerIp);
#ifdef HAS_HTTPS_TRACKER_VALIDATION
// Validate HTTPS tracker certificate
m_checkBoxValidateHTTPSTrackerCertificate.setChecked(session->validateHTTPSTrackerCertificate());
addRow(VALIDATE_HTTPS_TRACKER_CERTIFICATE, (tr("Validate HTTPS tracker certificates")
+ ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#validate_https_trackers", "(?)"))
, &m_checkBoxValidateHTTPSTrackerCertificate);
#endif
// Recheck completed torrents
m_checkBoxRecheckCompleted.setChecked(pref->recheckTorrentsOnCompletion());
addRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &m_checkBoxRecheckCompleted);