2016-09-29 21:19:54 +02:00
|
|
|
#include "./syncthingconnectionsettings.h"
|
|
|
|
|
2024-01-15 21:28:43 +01:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
2016-09-29 21:19:54 +02:00
|
|
|
namespace Data {
|
|
|
|
|
2023-12-30 20:38:15 +01:00
|
|
|
QList<QSslError> SyncthingConnectionSettings::compileSslErrors(const QSslCertificate &trustedCert)
|
|
|
|
{
|
|
|
|
// clang-format off
|
|
|
|
return QList<QSslError>{
|
|
|
|
QSslError(QSslError::UnableToGetLocalIssuerCertificate, trustedCert),
|
|
|
|
QSslError(QSslError::UnableToVerifyFirstCertificate, trustedCert),
|
|
|
|
QSslError(QSslError::SelfSignedCertificate, trustedCert),
|
|
|
|
QSslError(QSslError::HostNameMismatch, trustedCert),
|
|
|
|
QSslError(QSslError::CertificateUntrusted, trustedCert),
|
|
|
|
QSslError(QSslError::CertificateRejected, trustedCert)
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
}
|
|
|
|
|
2016-09-29 21:19:54 +02:00
|
|
|
bool SyncthingConnectionSettings::loadHttpsCert()
|
|
|
|
{
|
2016-10-02 21:59:28 +02:00
|
|
|
expectedSslErrors.clear();
|
2018-03-29 00:36:42 +02:00
|
|
|
if (httpsCertPath.isEmpty()) {
|
|
|
|
return true;
|
2016-09-29 21:19:54 +02:00
|
|
|
}
|
2023-12-30 20:38:58 +01:00
|
|
|
const auto certs = QSslCertificate::fromPath(httpsCertPath);
|
2023-12-30 20:38:15 +01:00
|
|
|
if (certs.isEmpty() || certs.at(0).isNull()) {
|
2018-03-29 00:36:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
2023-12-30 20:38:15 +01:00
|
|
|
|
2024-01-15 21:28:43 +01:00
|
|
|
httpCertLastModified = QFileInfo(httpsCertPath).lastModified();
|
2023-12-30 20:38:15 +01:00
|
|
|
expectedSslErrors = compileSslErrors(certs.at(0));
|
2016-09-29 21:19:54 +02:00
|
|
|
return true;
|
|
|
|
}
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace Data
|