diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index fb7678f2..570e8424 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -29,6 +29,7 @@ set(GUI_SOURCE_FILES
src/CommandProcess.cpp
src/DataDownloader.cpp
src/DisplayIsValid.cpp
+ src/FingerprintAcceptDialog.cpp
src/HotkeyDialog.cpp
src/IpcClient.cpp
src/Ipc.cpp
@@ -104,6 +105,7 @@ set(GUI_UI_FILES
src/AboutDialogBase.ui
src/ActionDialogBase.ui
src/AddClientDialogBase.ui
+ src/FingerprintAcceptDialog.ui
src/HotkeyDialogBase.ui
src/LogWindowBase.ui
src/MainWindowBase.ui
diff --git a/src/gui/src/FingerprintAcceptDialog.cpp b/src/gui/src/FingerprintAcceptDialog.cpp
new file mode 100644
index 00000000..e0dc7e60
--- /dev/null
+++ b/src/gui/src/FingerprintAcceptDialog.cpp
@@ -0,0 +1,65 @@
+/*
+ barrier -- mouse and keyboard sharing utility
+ Copyright (C) Barrier contributors
+
+ This package is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ found in the file LICENSE that should have accompanied this file.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+#include "FingerprintAcceptDialog.h"
+#include "ui_FingerprintAcceptDialog.h"
+#include "net/SecureUtils.h"
+
+FingerprintAcceptDialog::FingerprintAcceptDialog(QWidget *parent,
+ BarrierType type,
+ const barrier::FingerprintData& fingerprint_sha1,
+ const barrier::FingerprintData& fingerprint_sha256) :
+ QDialog(parent),
+ ui_{std::make_unique()}
+{
+ ui_->setupUi(this);
+
+ if (type == BarrierType::Server) {
+ ui_->label_sha1->hide();
+ ui_->label_sha1_fingerprint_full->hide();
+ } else {
+ ui_->label_sha1_fingerprint_full->setText(
+ QString::fromStdString(barrier::format_ssl_fingerprint(fingerprint_sha1.data)));
+ }
+
+ ui_->label_sha256_fingerprint_full->setText(
+ QString::fromStdString(barrier::format_ssl_fingerprint_columns(fingerprint_sha256.data)));
+ ui_->label_sha256_fingerprint_randomart->setText(
+ QString::fromStdString(barrier::create_fingerprint_randomart(fingerprint_sha256.data)));
+
+ QString explanation;
+ if (type == BarrierType::Server) {
+ explanation = tr("This is a client fingerprint. You should compare this "
+ "fingerprint to the one on your client's screen. If the "
+ "two don't match exactly, then it's probably not the client "
+ "you're expecting (it could be a malicious user).\n\n"
+ "To automatically trust this fingerprint for future "
+ "connections, click Yes. To reject this fingerprint and "
+ "disconnect the client, click No.");
+ } else {
+ explanation = tr("This is a server fingerprint. You should compare this "
+ "fingerprint to the one on your server's screen. If the "
+ "two don't match exactly, then it's probably not the server "
+ "you're expecting (it could be a malicious user).\n\n"
+ "To automatically trust this fingerprint for future "
+ "connections, click Yes. To reject this fingerprint and "
+ "disconnect from the server, click No.");
+ }
+ ui_->label_explanation->setText(explanation);
+}
+
+FingerprintAcceptDialog::~FingerprintAcceptDialog() = default;
diff --git a/src/gui/src/FingerprintAcceptDialog.h b/src/gui/src/FingerprintAcceptDialog.h
new file mode 100644
index 00000000..da8884c9
--- /dev/null
+++ b/src/gui/src/FingerprintAcceptDialog.h
@@ -0,0 +1,45 @@
+/*
+ barrier -- mouse and keyboard sharing utility
+ Copyright (C) Barrier contributors
+
+ This package is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ found in the file LICENSE that should have accompanied this file.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+#ifndef BARRIER_GUI_FINGERPRINT_ACCEPT_DIALOG_H
+#define BARRIER_GUI_FINGERPRINT_ACCEPT_DIALOG_H
+
+#include "net/FingerprintData.h"
+#include "barrier/BarrierType.h"
+#include
+#include
+
+namespace Ui {
+class FingerprintAcceptDialog;
+}
+
+class FingerprintAcceptDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit FingerprintAcceptDialog(QWidget* parent,
+ BarrierType type,
+ const barrier::FingerprintData& fingerprint_sha1,
+ const barrier::FingerprintData& fingerprint_sha256);
+ ~FingerprintAcceptDialog() override;
+
+private:
+ std::unique_ptr ui_;
+};
+
+#endif // BARRIER_GUI_FINGERPRINT_ACCEPT_DIALOG_H
diff --git a/src/gui/src/FingerprintAcceptDialog.ui b/src/gui/src/FingerprintAcceptDialog.ui
new file mode 100644
index 00000000..9c181ec3
--- /dev/null
+++ b/src/gui/src/FingerprintAcceptDialog.ui
@@ -0,0 +1,174 @@
+
+
+ FingerprintAcceptDialog
+
+
+
+ 0
+ 0
+ 600
+ 400
+
+
+
+
+ 0
+ 0
+
+
+
+ Security question
+
+
+
+ QLayout::SetFixedSize
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::No|QDialogButtonBox::Yes
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ SHA1 (deprecated, compare to old servers only)
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ true
+
+
+ 10
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
+
+
+
+ -
+
+
+ Do you trust this fingerprint?
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ Courier
+ 75
+ true
+
+
+
+
+
+
+ Qt::AlignCenter
+
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
+
+
+
+ -
+
+
+
+
+
+ Qt::AlignCenter
+
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
+
+
+
+ -
+
+
+ SHA256:
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ FingerprintAcceptDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ FingerprintAcceptDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp
index 85fa830e..d17548a4 100644
--- a/src/gui/src/MainWindow.cpp
+++ b/src/gui/src/MainWindow.cpp
@@ -26,6 +26,7 @@
#include "ZeroconfService.h"
#include "DataDownloader.h"
#include "CommandProcess.h"
+#include "FingerprintAcceptDialog.h"
#include "QUtility.h"
#include "ProcessorArch.h"
#include "SslCertificate.h"
@@ -469,50 +470,9 @@ void MainWindow::checkFingerprint(const QString& line)
stopBarrier();
}
- QString message;
- if (is_client) {
- message = tr("Do you trust this fingerprint?\n\n"
- "SHA256:\n"
- "%1\n"
- "%2\n\n"
- "SHA1 (obsolete, when using old Barrier client):\n"
- "%3\n\n"
- "This is a server fingerprint. You should compare this "
- "fingerprint to the one on your server's screen. If the "
- "two don't match exactly, then it's probably not the server "
- "you're expecting (it could be a malicious user).\n\n"
- "To automatically trust this fingerprint for future "
- "connections, click Yes. To reject this fingerprint and "
- "disconnect from the server, click No.")
- .arg(QString::fromStdString(barrier::format_ssl_fingerprint(fingerprint_sha256.data)))
- .arg(QString::fromStdString(
- barrier::create_fingerprint_randomart(fingerprint_sha256.data)))
- .arg(QString::fromStdString(barrier::format_ssl_fingerprint(fingerprint_sha1.data)));
- } else {
- message = tr("Do you trust this fingerprint?\n\n"
- "SHA256:\n"
- "%1\n"
- "%2\n\n"
- "This is a client fingerprint. You should compare this "
- "fingerprint to the one on your client's screen. If the "
- "two don't match exactly, then it's probably not the client "
- "you're expecting (it could be a malicious user).\n\n"
- "To automatically trust this fingerprint for future "
- "connections, click Yes. To reject this fingerprint and "
- "disconnect the client, click No.")
- .arg(QString::fromStdString(barrier::format_ssl_fingerprint(fingerprint_sha256.data)))
- .arg(QString::fromStdString(
- barrier::create_fingerprint_randomart(fingerprint_sha256.data)));
- }
-
messageBoxAlreadyShown = true;
- QMessageBox::StandardButton fingerprintReply =
- QMessageBox::information(
- this, tr("Security question"),
- message,
- QMessageBox::Yes | QMessageBox::No);
-
- if (fingerprintReply == QMessageBox::Yes) {
+ FingerprintAcceptDialog dialog{this, barrier_type(), fingerprint_sha1, fingerprint_sha256};
+ if (dialog.exec() == QDialog::Accepted) {
// restart core process after trusting fingerprint.
db.add_trusted(fingerprint_sha256);
db.write(db_path);