refactor: use a function to get the trustedFingerprintDb
This commit is contained in:
@ -734,13 +734,11 @@ void MainWindow::checkFingerprint(const QString &line)
|
||||
deskflow::string::fromHex(match.captured(2).toStdString())
|
||||
};
|
||||
|
||||
// Only Save the sha256
|
||||
const bool isClient = m_coreProcess.mode() == CoreMode::Client;
|
||||
const auto trustFile = isClient ? kFingerprintTrustedServersFilename : kFingerprintTrustedClientsFilename;
|
||||
const auto localPath = QStringLiteral("%1/%2").arg(getTlsPath(), trustFile).toStdString();
|
||||
|
||||
// Only Save the sha256
|
||||
deskflow::FingerprintDatabase db;
|
||||
db.read(localPath);
|
||||
db.read(trustedFingerprintDb().toStdString());
|
||||
if (db.isTrusted(sha256)) {
|
||||
return;
|
||||
}
|
||||
@ -755,7 +753,7 @@ void MainWindow::checkFingerprint(const QString &line)
|
||||
);
|
||||
if (fingerprintDialog.exec() == QDialog::Accepted) {
|
||||
db.addTrusted(sha256);
|
||||
db.write(localPath);
|
||||
db.write(trustedFingerprintDb().toStdString());
|
||||
m_coreProcess.start();
|
||||
}
|
||||
}
|
||||
@ -1078,6 +1076,13 @@ QString MainWindow::localFingerPrintDb()
|
||||
return QStringLiteral("%1/%2").arg(getTlsPath(), kFingerprintLocalFilename);
|
||||
}
|
||||
|
||||
QString MainWindow::trustedFingerprintDb()
|
||||
{
|
||||
const bool isClient = m_coreProcess.mode() == CoreMode::Client;
|
||||
const auto trustFile = isClient ? kFingerprintTrustedServersFilename : kFingerprintTrustedClientsFilename;
|
||||
return QStringLiteral("%1/%2").arg(getTlsPath(), trustFile);
|
||||
}
|
||||
|
||||
bool MainWindow::regenerateLocalFingerprints()
|
||||
{
|
||||
if (!QFile::exists(m_appConfig.tlsCertPath()) && !m_tlsUtility.generateCertificate()) {
|
||||
|
||||
@ -168,6 +168,12 @@ private:
|
||||
QString getTlsPath();
|
||||
QString localFingerPrintDb();
|
||||
|
||||
/**
|
||||
* @brief trustedFingerprintDb get the fingerprintDb for the trusted clients or trusted servers.
|
||||
* @return The path to the trusted fingerprint file
|
||||
*/
|
||||
QString trustedFingerprintDb();
|
||||
|
||||
// Generate prints if they are missing
|
||||
// Returns true if successful
|
||||
bool regenerateLocalFingerprints();
|
||||
|
||||
Reference in New Issue
Block a user