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