refactor: new Setting::tlsTrustedServersDb() method to return trusted server fingerprint db

This commit is contained in:
sithlord48
2025-03-17 21:41:14 -04:00
committed by Nick Bolton
parent dcd2c62880
commit 38f00da704
4 changed files with 8 additions and 4 deletions

View File

@ -1146,7 +1146,7 @@ void MainWindow::setHostName()
QString MainWindow::trustedFingerprintDb()
{
const bool isClient = m_coreProcess.mode() == CoreMode::Client;
const auto trustFile = isClient ? kTlsFingerprintTrustedServersFilename : kTlsFingerprintTrustedClientsFilename;
const auto trustFile = isClient ? Settings::tlsTrustedServersDb() : kTlsFingerprintTrustedClientsFilename;
return QStringLiteral("%1/%2").arg(Settings::tlsDir(), trustFile);
}

View File

@ -171,6 +171,11 @@ const QString Settings::tlsLocalDb()
return QStringLiteral("%1/%2").arg(instance()->tlsDir(), kTlsFingerprintLocalFilename);
}
const QString Settings::tlsTrustedServersDb()
{
return QStringLiteral("%1/%2").arg(instance()->tlsDir(), kTlsFingerprintTrustedServersFilename);
}
void Settings::setValue(const QString &key, const QVariant &value)
{
if (instance()->m_settings->value(key) == value)

View File

@ -143,6 +143,7 @@ public:
static const QString settingsPath();
static const QString tlsDir();
static const QString tlsLocalDb();
static const QString tlsTrustedServersDb();
static const QString logLevelText();
static QSettingsProxy &proxy();
static void save(bool emitSaving = true);

View File

@ -524,9 +524,7 @@ int SecureSocket::secureConnect(int socket)
retry = 0;
// No error, set ready, process and return ok
m_secureReady = true;
std::string dbDir = deskflow::string::sprintf(
"%s/%s", Settings::tlsDir().toStdString().c_str(), kTlsFingerprintTrustedServersFilename
);
std::string dbDir = Settings::tlsTrustedServersDb().toStdString().c_str();
if (verifyCertFingerprint(dbDir)) {
LOG((CLOG_INFO "connected to secure socket"));
if (!showCertificate()) {