|
|
@ -75,18 +75,13 @@ void WebUI::init() |
|
|
|
|
|
|
|
|
|
|
|
#ifndef QT_NO_OPENSSL |
|
|
|
#ifndef QT_NO_OPENSSL |
|
|
|
if (pref->isWebUiHttpsEnabled()) { |
|
|
|
if (pref->isWebUiHttpsEnabled()) { |
|
|
|
const QByteArray keyRaw = pref->getWebUiHttpsKey(); |
|
|
|
const QByteArray certs = pref->getWebUiHttpsCertificate(); |
|
|
|
QSslKey key(keyRaw, QSsl::Rsa); |
|
|
|
const QByteArray key = pref->getWebUiHttpsKey(); |
|
|
|
if (key.isNull()) |
|
|
|
bool success = m_httpServer->setupHttps(certs, key); |
|
|
|
key = QSslKey(keyRaw, QSsl::Ec); |
|
|
|
if (success) |
|
|
|
|
|
|
|
logger->addMessage(tr("Web UI: https setup successful")); |
|
|
|
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); |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
m_httpServer->disableHttps(); |
|
|
|
logger->addMessage(tr("Web UI: https setup failed, fallback to http"), Log::CRITICAL); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
m_httpServer->disableHttps(); |
|
|
|
m_httpServer->disableHttps(); |
|
|
|