Improve coding style in SyncthingConnectionSettings::loadHttpsCert()
This commit is contained in:
parent
419e2971c1
commit
e6642245df
|
@ -5,17 +5,22 @@ namespace Data {
|
||||||
bool SyncthingConnectionSettings::loadHttpsCert()
|
bool SyncthingConnectionSettings::loadHttpsCert()
|
||||||
{
|
{
|
||||||
expectedSslErrors.clear();
|
expectedSslErrors.clear();
|
||||||
if (!httpsCertPath.isEmpty()) {
|
if (httpsCertPath.isEmpty()) {
|
||||||
const QList<QSslCertificate> cert = QSslCertificate::fromPath(httpsCertPath);
|
return true;
|
||||||
if (cert.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
expectedSslErrors.reserve(4);
|
|
||||||
expectedSslErrors << QSslError(QSslError::UnableToGetLocalIssuerCertificate, cert.at(0));
|
|
||||||
expectedSslErrors << QSslError(QSslError::UnableToVerifyFirstCertificate, cert.at(0));
|
|
||||||
expectedSslErrors << QSslError(QSslError::SelfSignedCertificate, cert.at(0));
|
|
||||||
expectedSslErrors << QSslError(QSslError::HostNameMismatch, cert.at(0));
|
|
||||||
}
|
}
|
||||||
|
const auto certs(QSslCertificate::fromPath(httpsCertPath));
|
||||||
|
if (certs.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto &cert(certs.front());
|
||||||
|
// clang-format off
|
||||||
|
expectedSslErrors = {
|
||||||
|
QSslError(QSslError::UnableToGetLocalIssuerCertificate, cert),
|
||||||
|
QSslError(QSslError::UnableToVerifyFirstCertificate, cert),
|
||||||
|
QSslError(QSslError::SelfSignedCertificate, cert),
|
||||||
|
QSslError(QSslError::HostNameMismatch, cert)
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
Loading…
Reference in New Issue