refactor: MainWindow keep a local copy of the fingerprint
This also makes it so MainWindow does not use the local_fingerprint file
This commit is contained in:
parent
2087097415
commit
4698326717
2 changed files with 8 additions and 45 deletions
|
|
@ -140,7 +140,7 @@ MainWindow::MainWindow()
|
||||||
|
|
||||||
qDebug().noquote() << "active settings path:" << Settings::settingsPath();
|
qDebug().noquote() << "active settings path:" << Settings::settingsPath();
|
||||||
|
|
||||||
// Force generation of SHA256 for the localhost
|
// Force generation of a certificate on the host
|
||||||
if (TlsUtility::isEnabled()) {
|
if (TlsUtility::isEnabled()) {
|
||||||
if (Settings::value(Settings::Security::KeySize).toInt() < 2048) {
|
if (Settings::value(Settings::Security::KeySize).toInt() < 2048) {
|
||||||
QMessageBox::information(
|
QMessageBox::information(
|
||||||
|
|
@ -151,22 +151,11 @@ MainWindow::MainWindow()
|
||||||
}
|
}
|
||||||
if (!TlsUtility::isCertValid()) {
|
if (!TlsUtility::isCertValid()) {
|
||||||
generateCertificate();
|
generateCertificate();
|
||||||
return;
|
} else {
|
||||||
}
|
m_fingerprint = {Fingerprint::Type::SHA256, TlsUtility::certFingerprint()};
|
||||||
|
|
||||||
if (!QFile::exists(Settings::tlsLocalDb())) {
|
|
||||||
generateCertificate();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FingerprintDatabase db;
|
|
||||||
db.read(Settings::tlsLocalDb());
|
|
||||||
if (db.fingerprints().isEmpty()) {
|
|
||||||
generateCertificate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
m_guiDupeChecker->close();
|
m_guiDupeChecker->close();
|
||||||
|
|
@ -501,7 +490,7 @@ void MainWindow::resetCore()
|
||||||
|
|
||||||
void MainWindow::showMyFingerprint()
|
void MainWindow::showMyFingerprint()
|
||||||
{
|
{
|
||||||
FingerprintDialog fingerprintDialog(this, localFingerprint());
|
FingerprintDialog fingerprintDialog(this, m_fingerprint);
|
||||||
fingerprintDialog.exec();
|
fingerprintDialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -838,7 +827,7 @@ void MainWindow::checkFingerprint(const QString &line)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mode = isClient ? FingerprintDialogMode::Client : FingerprintDialogMode::Server;
|
auto mode = isClient ? FingerprintDialogMode::Client : FingerprintDialogMode::Server;
|
||||||
FingerprintDialog fingerprintDialog(this, localFingerprint(), mode, sha256);
|
FingerprintDialog fingerprintDialog(this, m_fingerprint, mode, sha256);
|
||||||
|
|
||||||
if (fingerprintDialog.exec() == QDialog::Accepted) {
|
if (fingerprintDialog.exec() == QDialog::Accepted) {
|
||||||
db.addTrusted(sha256);
|
db.addTrusted(sha256);
|
||||||
|
|
@ -1016,7 +1005,7 @@ void MainWindow::coreConnectionStateChanged(CoreConnectionState state)
|
||||||
|
|
||||||
void MainWindow::updateLocalFingerprint()
|
void MainWindow::updateLocalFingerprint()
|
||||||
{
|
{
|
||||||
m_btnFingerprint->setVisible(TlsUtility::isEnabled() && QFile::exists(Settings::tlsLocalDb()));
|
m_btnFingerprint->setVisible(TlsUtility::isEnabled() && !m_fingerprint.data.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::hide()
|
void MainWindow::hide()
|
||||||
|
|
@ -1188,38 +1177,12 @@ bool MainWindow::generateCertificate()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TlsCertificate tls; !tls.generateFingerprint(certificate)) {
|
m_fingerprint = {Fingerprint::Type::SHA256, TlsUtility::certFingerprint()};
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLocalFingerprint();
|
updateLocalFingerprint();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fingerprint MainWindow::localFingerprint()
|
|
||||||
{
|
|
||||||
if (!QFile::exists(Settings::tlsLocalDb())) {
|
|
||||||
if (generateCertificate())
|
|
||||||
return localFingerprint();
|
|
||||||
}
|
|
||||||
|
|
||||||
FingerprintDatabase db;
|
|
||||||
db.read(Settings::tlsLocalDb());
|
|
||||||
if (db.fingerprints().isEmpty()) {
|
|
||||||
if (generateCertificate())
|
|
||||||
return localFingerprint();
|
|
||||||
}
|
|
||||||
|
|
||||||
Fingerprint sha256Print;
|
|
||||||
for (const auto &f : std::as_const(db.fingerprints())) {
|
|
||||||
if (f.type == Fingerprint::Type::SHA256) {
|
|
||||||
sha256Print = f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sha256Print;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::serverClientsChanged(const QStringList &clients)
|
void MainWindow::serverClientsChanged(const QStringList &clients)
|
||||||
{
|
{
|
||||||
if (m_coreProcess.mode() != CoreMode::Server || !m_coreProcess.isStarted())
|
if (m_coreProcess.mode() != CoreMode::Server || !m_coreProcess.isStarted())
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ private:
|
||||||
*/
|
*/
|
||||||
bool generateCertificate();
|
bool generateCertificate();
|
||||||
|
|
||||||
Fingerprint localFingerprint();
|
Fingerprint m_fingerprint;
|
||||||
|
|
||||||
void serverClientsChanged(const QStringList &clients);
|
void serverClientsChanged(const QStringList &clients);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue