diff --git a/src/base/http/server.cpp b/src/base/http/server.cpp index 0895b5f57..f69f31298 100644 --- a/src/base/http/server.cpp +++ b/src/base/http/server.cpp @@ -52,9 +52,9 @@ Server::~Server() } #ifndef QT_NO_OPENSSL -void Server::enableHttps(const QSslCertificate &certificate, const QSslKey &key) +void Server::enableHttps(const QList &certificates, const QSslKey &key) { - m_certificate = certificate; + m_certificates = certificates; m_key = key; m_https = true; } @@ -62,7 +62,7 @@ void Server::enableHttps(const QSslCertificate &certificate, const QSslKey &key) void Server::disableHttps() { m_https = false; - m_certificate.clear(); + m_certificates.clear(); m_key.clear(); } #endif @@ -84,9 +84,13 @@ void Server::incomingConnection(int socketDescriptor) if (serverSocket->setSocketDescriptor(socketDescriptor)) { #ifndef QT_NO_OPENSSL if (m_https) { - static_cast(serverSocket)->setProtocol(QSsl::AnyProtocol); + static_cast(serverSocket)->setProtocol(QSsl::SecureProtocols); static_cast(serverSocket)->setPrivateKey(m_key); - static_cast(serverSocket)->setLocalCertificate(m_certificate); +#ifdef QBT_USES_QT5 + static_cast(serverSocket)->setLocalCertificateChain(m_certificates); +#else + static_cast(serverSocket)->setLocalCertificate(m_certificates.first()); +#endif static_cast(serverSocket)->startServerEncryption(); } #endif diff --git a/src/base/http/server.h b/src/base/http/server.h index 64920e2e8..bc1f6d493 100644 --- a/src/base/http/server.h +++ b/src/base/http/server.h @@ -54,7 +54,7 @@ namespace Http ~Server(); #ifndef QT_NO_OPENSSL - void enableHttps(const QSslCertificate &certificate, const QSslKey &key); + void enableHttps(const QList &certificates, const QSslKey &key); void disableHttps(); #endif @@ -69,7 +69,7 @@ namespace Http IRequestHandler *m_requestHandler; #ifndef QT_NO_OPENSSL bool m_https; - QSslCertificate m_certificate; + QList m_certificates; QSslKey m_key; #endif }; diff --git a/src/webui/webui.cpp b/src/webui/webui.cpp index 93add39c7..e4d5d62b1 100644 --- a/src/webui/webui.cpp +++ b/src/webui/webui.cpp @@ -65,11 +65,12 @@ void WebUI::init() #ifndef QT_NO_OPENSSL if (pref->isWebUiHttpsEnabled()) { - QSslCertificate cert(pref->getWebUiHttpsCertificate()); + QList certs = QSslCertificate::fromData(pref->getWebUiHttpsCertificate()); QSslKey key; key = QSslKey(pref->getWebUiHttpsKey(), QSsl::Rsa); - if (!cert.isNull() && !key.isNull()) - httpServer_->enableHttps(cert, key); + bool certsIsNull = std::any_of(certs.begin(), certs.end(), [](QSslCertificate c) { return c.isNull(); }); + if (!certsIsNull && !certs.empty() && !key.isNull()) + httpServer_->enableHttps(certs, key); else httpServer_->disableHttps(); }