mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-29 16:04:21 +00:00
Merge pull request #4904 from UnDifferential/master
Support SSL certificate bundles. Closes #4896.
This commit is contained in:
commit
b11ab06bb2
@ -52,9 +52,9 @@ Server::~Server()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
void Server::enableHttps(const QSslCertificate &certificate, const QSslKey &key)
|
void Server::enableHttps(const QList<QSslCertificate> &certificates, const QSslKey &key)
|
||||||
{
|
{
|
||||||
m_certificate = certificate;
|
m_certificates = certificates;
|
||||||
m_key = key;
|
m_key = key;
|
||||||
m_https = true;
|
m_https = true;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ void Server::enableHttps(const QSslCertificate &certificate, const QSslKey &key)
|
|||||||
void Server::disableHttps()
|
void Server::disableHttps()
|
||||||
{
|
{
|
||||||
m_https = false;
|
m_https = false;
|
||||||
m_certificate.clear();
|
m_certificates.clear();
|
||||||
m_key.clear();
|
m_key.clear();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -84,9 +84,13 @@ void Server::incomingConnection(int socketDescriptor)
|
|||||||
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
|
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
if (m_https) {
|
if (m_https) {
|
||||||
static_cast<QSslSocket*>(serverSocket)->setProtocol(QSsl::AnyProtocol);
|
static_cast<QSslSocket*>(serverSocket)->setProtocol(QSsl::SecureProtocols);
|
||||||
static_cast<QSslSocket*>(serverSocket)->setPrivateKey(m_key);
|
static_cast<QSslSocket*>(serverSocket)->setPrivateKey(m_key);
|
||||||
static_cast<QSslSocket*>(serverSocket)->setLocalCertificate(m_certificate);
|
#ifdef QBT_USES_QT5
|
||||||
|
static_cast<QSslSocket*>(serverSocket)->setLocalCertificateChain(m_certificates);
|
||||||
|
#else
|
||||||
|
static_cast<QSslSocket*>(serverSocket)->setLocalCertificate(m_certificates.first());
|
||||||
|
#endif
|
||||||
static_cast<QSslSocket*>(serverSocket)->startServerEncryption();
|
static_cast<QSslSocket*>(serverSocket)->startServerEncryption();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,7 +54,7 @@ namespace Http
|
|||||||
~Server();
|
~Server();
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
void enableHttps(const QSslCertificate &certificate, const QSslKey &key);
|
void enableHttps(const QList<QSslCertificate> &certificates, const QSslKey &key);
|
||||||
void disableHttps();
|
void disableHttps();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ namespace Http
|
|||||||
IRequestHandler *m_requestHandler;
|
IRequestHandler *m_requestHandler;
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
bool m_https;
|
bool m_https;
|
||||||
QSslCertificate m_certificate;
|
QList<QSslCertificate> m_certificates;
|
||||||
QSslKey m_key;
|
QSslKey m_key;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -65,11 +65,12 @@ void WebUI::init()
|
|||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
if (pref->isWebUiHttpsEnabled()) {
|
if (pref->isWebUiHttpsEnabled()) {
|
||||||
QSslCertificate cert(pref->getWebUiHttpsCertificate());
|
QList<QSslCertificate> certs = QSslCertificate::fromData(pref->getWebUiHttpsCertificate());
|
||||||
QSslKey key;
|
QSslKey key;
|
||||||
key = QSslKey(pref->getWebUiHttpsKey(), QSsl::Rsa);
|
key = QSslKey(pref->getWebUiHttpsKey(), QSsl::Rsa);
|
||||||
if (!cert.isNull() && !key.isNull())
|
bool certsIsNull = std::any_of(certs.begin(), certs.end(), [](QSslCertificate c) { return c.isNull(); });
|
||||||
httpServer_->enableHttps(cert, key);
|
if (!certsIsNull && !certs.empty() && !key.isNull())
|
||||||
|
httpServer_->enableHttps(certs, key);
|
||||||
else
|
else
|
||||||
httpServer_->disableHttps();
|
httpServer_->disableHttps();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user