mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-31 03:50:20 -07:00
Refactor: move the validation of certificates & key functions under Server class
Rename method Add log messages
This commit is contained in:
parent
05d8c46bb0
commit
7f346b49a7
3 changed files with 27 additions and 16 deletions
|
@ -75,18 +75,13 @@ void WebUI::init()
|
|||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
if (pref->isWebUiHttpsEnabled()) {
|
||||
const QByteArray keyRaw = pref->getWebUiHttpsKey();
|
||||
QSslKey key(keyRaw, QSsl::Rsa);
|
||||
if (key.isNull())
|
||||
key = QSslKey(keyRaw, QSsl::Ec);
|
||||
|
||||
const QList<QSslCertificate> certs = QSslCertificate::fromData(pref->getWebUiHttpsCertificate());
|
||||
const bool areCertsValid = !certs.empty() && std::all_of(certs.begin(), certs.end(), [](QSslCertificate c) { return !c.isNull(); });
|
||||
|
||||
if (!key.isNull() && areCertsValid)
|
||||
m_httpServer->enableHttps(certs, key);
|
||||
const QByteArray certs = pref->getWebUiHttpsCertificate();
|
||||
const QByteArray key = pref->getWebUiHttpsKey();
|
||||
bool success = m_httpServer->setupHttps(certs, key);
|
||||
if (success)
|
||||
logger->addMessage(tr("Web UI: https setup successful"));
|
||||
else
|
||||
m_httpServer->disableHttps();
|
||||
logger->addMessage(tr("Web UI: https setup failed, fallback to http"), Log::CRITICAL);
|
||||
}
|
||||
else {
|
||||
m_httpServer->disableHttps();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue