Add option to disable SSL validation. (Not encouraged!!!) #48

This commit is contained in:
Ian Walton 2021-04-19 21:26:36 -04:00
parent 3afcb3fc86
commit 344aba88f1
6 changed files with 47 additions and 23 deletions

View File

@ -11,6 +11,10 @@
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"qnetworkaccessmanager": "cpp"
"qnetworkaccessmanager": "cpp",
"array": "cpp",
"tuple": "cpp",
"utility": "cpp",
"variant": "cpp"
}
}

View File

@ -123,6 +123,11 @@
{
"value": "enableInputRepeat",
"default": true
},
{
"value": "ignoreSSLErrors",
"default": false,
"hidden": true
}
]
},

View File

@ -128,35 +128,40 @@ bool PlayerComponent::componentInitialize()
// See: https://github.com/plexinc/plex-media-player/issues/736
mpv::qt::set_property(m_mpv, "cache-seek-min", 5000);
if (!SettingsComponent::Get().ignoreSSLErrors()) {
mpv::qt::set_property(m_mpv, "tls-ca-file", "");
mpv::qt::set_property(m_mpv, "tls-verify", "no");
} else {
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
QList<QByteArray> list;
list << "/etc/ssl/certs/ca-certificates.crt"
<< "/etc/pki/tls/certs/ca-bundle.crt"
<< "/usr/share/ssl/certs/ca-bundle.crt"
<< "/usr/local/share/certs/ca-root-nss.crt"
<< "/etc/ssl/cert.pem"
<< "/usr/share/curl/curl-ca-bundle.crt"
<< "/usr/local/share/curl/curl-ca-bundle.crt"
<< "/var/lib/ca-certificates/ca-bundle.pem";
QList<QByteArray> list;
list << "/etc/ssl/certs/ca-certificates.crt"
<< "/etc/pki/tls/certs/ca-bundle.crt"
<< "/usr/share/ssl/certs/ca-bundle.crt"
<< "/usr/local/share/certs/ca-root-nss.crt"
<< "/etc/ssl/cert.pem"
<< "/usr/share/curl/curl-ca-bundle.crt"
<< "/usr/local/share/curl/curl-ca-bundle.crt"
<< "/var/lib/ca-certificates/ca-bundle.pem";
bool success = false;
bool success = false;
for (auto path : list)
{
if (access(path.data(), R_OK) == 0) {
mpv::qt::set_property(m_mpv, "tls-ca-file", path.data());
mpv::qt::set_property(m_mpv, "tls-verify", "yes");
success = true;
break;
for (auto path : list)
{
if (access(path.data(), R_OK) == 0) {
mpv::qt::set_property(m_mpv, "tls-ca-file", path.data());
mpv::qt::set_property(m_mpv, "tls-verify", "yes");
success = true;
break;
}
}
}
if (!success)
throw FatalException(tr("Failed to locate CA bundle."));
if (!success)
throw FatalException(tr("Failed to locate CA bundle."));
#else
// We need to not use Shinchiro's personal CA file...
mpv::qt::set_property(m_mpv, "tls-ca-file", "");
// We need to not use Shinchiro's personal CA file...
mpv::qt::set_property(m_mpv, "tls-ca-file", "");
#endif
}
// Apply some low-memory settings on RPI, which is relatively memory-constrained.
#ifdef TARGET_RPI

View File

@ -753,6 +753,12 @@ QString SettingsComponent::getClientName()
return name;
}
/////////////////////////////////////////////////////////////////////////////////////////
bool SettingsComponent::ignoreSSLErrors()
{
return SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "ignoreSSLErrors").toBool();
}
/////////////////////////////////////////////////////////////////////////////////////////
void SettingsComponent::setCommandLineValues(const QStringList& values)
{

View File

@ -60,6 +60,7 @@ public:
Q_INVOKABLE QString getWebClientUrl(bool desktop);
Q_INVOKABLE QString getExtensionPath();
Q_INVOKABLE QString getClientName();
Q_INVOKABLE bool ignoreSSLErrors();
// host commands
Q_SLOT Q_INVOKABLE void cycleSettingCommand(const QString& args);

View File

@ -216,6 +216,9 @@ KonvergoWindow
onCertificateError:
{
console.log(error.url + " :" + error.description + error.error)
if (components.settings.ignoreSSLErrors()) {
error.ignoreCertificateError()
}
}
}