refactor: new Setting::tlsLocalDb() method to return local fingerprint db
This commit is contained in:
@ -148,13 +148,13 @@ MainWindow::MainWindow()
|
||||
|
||||
// Force generation of SHA256 for the localhost
|
||||
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
||||
if (!QFile::exists(localFingerprintDb())) {
|
||||
if (!QFile::exists(Settings::tlsLocalDb())) {
|
||||
regenerateLocalFingerprints();
|
||||
return;
|
||||
}
|
||||
|
||||
deskflow::FingerprintDatabase db;
|
||||
db.read(localFingerprintDb().toStdString());
|
||||
db.read(Settings::tlsLocalDb().toStdString());
|
||||
if (db.fingerprints().size() != kTlsDbSize) {
|
||||
regenerateLocalFingerprints();
|
||||
}
|
||||
@ -528,14 +528,14 @@ void MainWindow::updateSize()
|
||||
|
||||
void MainWindow::showMyFingerprint()
|
||||
{
|
||||
if (!QFile::exists(localFingerprintDb())) {
|
||||
if (!QFile::exists(Settings::tlsLocalDb())) {
|
||||
if (regenerateLocalFingerprints())
|
||||
showMyFingerprint();
|
||||
return;
|
||||
}
|
||||
|
||||
deskflow::FingerprintDatabase db;
|
||||
db.read(localFingerprintDb().toStdString());
|
||||
db.read(Settings::tlsLocalDb().toStdString());
|
||||
if (db.fingerprints().size() != kTlsDbSize) {
|
||||
if (regenerateLocalFingerprints())
|
||||
showMyFingerprint();
|
||||
@ -1029,7 +1029,7 @@ QString MainWindow::getIPAddresses() const
|
||||
void MainWindow::updateLocalFingerprint()
|
||||
{
|
||||
const bool tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||
m_btnFingerprint->setVisible(tlsEnabled && QFile::exists(localFingerprintDb()));
|
||||
m_btnFingerprint->setVisible(tlsEnabled && QFile::exists(Settings::tlsLocalDb()));
|
||||
}
|
||||
|
||||
void MainWindow::autoAddScreen(const QString name)
|
||||
@ -1143,11 +1143,6 @@ void MainWindow::setHostName()
|
||||
applyConfig();
|
||||
}
|
||||
|
||||
QString MainWindow::localFingerprintDb()
|
||||
{
|
||||
return QStringLiteral("%1/%2").arg(Settings::tlsDir(), kTlsFingerprintLocalFilename);
|
||||
}
|
||||
|
||||
QString MainWindow::trustedFingerprintDb()
|
||||
{
|
||||
const bool isClient = m_coreProcess.mode() == CoreMode::Client;
|
||||
|
||||
@ -161,12 +161,6 @@ private:
|
||||
void showHostNameEditor();
|
||||
void setHostName();
|
||||
|
||||
/**
|
||||
* @brief localFingerprintDb
|
||||
* @return The path to the local fingerprint file
|
||||
*/
|
||||
QString localFingerprintDb();
|
||||
|
||||
/**
|
||||
* @brief trustedFingerprintDb get the fingerprintDb for the trusted clients or trusted servers.
|
||||
* @return The path to the trusted fingerprint file
|
||||
|
||||
@ -166,6 +166,11 @@ const QString Settings::tlsDir()
|
||||
return QStringLiteral("%1/%2").arg(instance()->settingsPath(), kTlsDirName);
|
||||
}
|
||||
|
||||
const QString Settings::tlsLocalDb()
|
||||
{
|
||||
return QStringLiteral("%1/%2").arg(instance()->tlsDir(), kTlsFingerprintLocalFilename);
|
||||
}
|
||||
|
||||
void Settings::setValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
if (instance()->m_settings->value(key) == value)
|
||||
|
||||
@ -142,6 +142,7 @@ public:
|
||||
static const QString settingsFile();
|
||||
static const QString settingsPath();
|
||||
static const QString tlsDir();
|
||||
static const QString tlsLocalDb();
|
||||
static const QString logLevelText();
|
||||
static QSettingsProxy &proxy();
|
||||
static void save(bool emitSaving = true);
|
||||
|
||||
@ -55,7 +55,7 @@ bool TlsCertificate::generateFingerprint(const QString &certificateFilename)
|
||||
deskflow::FingerprintDatabase db;
|
||||
db.addTrusted(deskflow::pemFileCertFingerprint(certPath, deskflow::FingerprintType::SHA1));
|
||||
db.addTrusted(deskflow::pemFileCertFingerprint(certPath, deskflow::FingerprintType::SHA256));
|
||||
db.write(QStringLiteral("%1/%2").arg(Settings::tlsDir(), kTlsFingerprintLocalFilename).toStdString());
|
||||
db.write(QStringLiteral("%1/%2").arg(Settings::tlsLocalDb()).toStdString());
|
||||
|
||||
qDebug("tls fingerprint generated");
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user