mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -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
|
@ -61,11 +61,27 @@ Server::~Server()
|
|||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void Server::enableHttps(const QList<QSslCertificate> &certificates, const QSslKey &key)
|
||||
bool Server::setupHttps(const QByteArray &certificates, const QByteArray &key)
|
||||
{
|
||||
m_certificates = certificates;
|
||||
m_key = key;
|
||||
m_https = true;
|
||||
QSslKey sslKey(key, QSsl::Rsa);
|
||||
if (sslKey.isNull())
|
||||
sslKey = QSslKey(key, QSsl::Ec);
|
||||
|
||||
const QList<QSslCertificate> certs = QSslCertificate::fromData(certificates);
|
||||
const bool areCertsValid = !certs.empty() && std::all_of(certs.begin(), certs.end(), [](const QSslCertificate &c) { return !c.isNull(); });
|
||||
|
||||
if (!sslKey.isNull() && areCertsValid)
|
||||
{
|
||||
m_key = sslKey;
|
||||
m_certificates = certs;
|
||||
m_https = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
disableHttps();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Server::disableHttps()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue