refactor: use a function to get the trustedFingerprintDb
This commit is contained in:
parent
bfb64f0653
commit
9294f2a026
2 changed files with 16 additions and 5 deletions
|
|
@ -734,13 +734,11 @@ void MainWindow::checkFingerprint(const QString &line)
|
||||||
deskflow::string::fromHex(match.captured(2).toStdString())
|
deskflow::string::fromHex(match.captured(2).toStdString())
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only Save the sha256
|
|
||||||
const bool isClient = m_coreProcess.mode() == CoreMode::Client;
|
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;
|
deskflow::FingerprintDatabase db;
|
||||||
db.read(localPath);
|
db.read(trustedFingerprintDb().toStdString());
|
||||||
if (db.isTrusted(sha256)) {
|
if (db.isTrusted(sha256)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -755,7 +753,7 @@ void MainWindow::checkFingerprint(const QString &line)
|
||||||
);
|
);
|
||||||
if (fingerprintDialog.exec() == QDialog::Accepted) {
|
if (fingerprintDialog.exec() == QDialog::Accepted) {
|
||||||
db.addTrusted(sha256);
|
db.addTrusted(sha256);
|
||||||
db.write(localPath);
|
db.write(trustedFingerprintDb().toStdString());
|
||||||
m_coreProcess.start();
|
m_coreProcess.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1078,6 +1076,13 @@ QString MainWindow::localFingerPrintDb()
|
||||||
return QStringLiteral("%1/%2").arg(getTlsPath(), kFingerprintLocalFilename);
|
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()
|
bool MainWindow::regenerateLocalFingerprints()
|
||||||
{
|
{
|
||||||
if (!QFile::exists(m_appConfig.tlsCertPath()) && !m_tlsUtility.generateCertificate()) {
|
if (!QFile::exists(m_appConfig.tlsCertPath()) && !m_tlsUtility.generateCertificate()) {
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,12 @@ private:
|
||||||
QString getTlsPath();
|
QString getTlsPath();
|
||||||
QString localFingerPrintDb();
|
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
|
// Generate prints if they are missing
|
||||||
// Returns true if successful
|
// Returns true if successful
|
||||||
bool regenerateLocalFingerprints();
|
bool regenerateLocalFingerprints();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue