From 92874037ed6b895c074ab44d5313a0a68732e62c Mon Sep 17 00:00:00 2001 From: SerhiiGadzhilov <71632867+SerhiiGadzhilov@users.noreply.github.com> Date: Fri, 6 Nov 2020 16:16:56 +0300 Subject: [PATCH] SYNERGY-545 TLS certificate error (#6832) * SYNERGY-545 TLS certificate error * #6832 TLS certificate error on macOS system --- ChangeLog | 1 + src/gui/src/AppConfig.cpp | 14 ++++++++++---- src/gui/src/AppConfig.h | 1 + src/gui/src/MainWindow.cpp | 9 +++++++-- src/gui/src/SettingsDialog.cpp | 6 ++---- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 722836e9e..f26ef9765 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ Bug fixes: - #6826 + #6829 SonarCloud Critical bugs - #6821 Blocker bugs found by sonar in synergy and in tests - #6825 The system requires google test even when tests are disabled with BUILD_TESTS=OFF +- #6832 TLS certificate error on macOS system Enhancements: - #6750 Integrate SonarCloud for static analysis and test coverage diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index d1040270c..30bfee49c 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -418,12 +418,18 @@ void AppConfig::setCryptoEnabled(bool newValue) { emit sslToggled(m_CryptoEnabled); } -bool AppConfig::getCryptoEnabled() const { - return +bool AppConfig::isCryptoAvailable() const { + bool result {true}; + #ifndef SYNERGY_ENTERPRISE - (edition() == kPro) && + result = (edition() == kPro || edition() == kBusiness); #endif - m_CryptoEnabled; + + return result; +} + +bool AppConfig::getCryptoEnabled() const { + return isCryptoAvailable() && m_CryptoEnabled; } void AppConfig::setAutoHide(bool b) { diff --git a/src/gui/src/AppConfig.h b/src/gui/src/AppConfig.h index 0f40a7049..5c7f71dbc 100644 --- a/src/gui/src/AppConfig.h +++ b/src/gui/src/AppConfig.h @@ -104,6 +104,7 @@ class AppConfig: public QObject, public GUI::Config::ConfigBase void persistLogDir(); ElevateMode elevateMode(); + bool isCryptoAvailable() const; void setCryptoEnabled(bool e); bool getCryptoEnabled() const; diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index ec2533d15..00028b8fe 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -665,17 +665,22 @@ void MainWindow::startSynergy() #endif +#if defined(Q_OS_WIN) if (m_AppConfig->getCryptoEnabled()) { args << "--enable-crypto"; args << "--tls-cert" << QString("\"%1\"").arg(m_AppConfig->getTLSCertPath()); } - -#if defined(Q_OS_WIN) // on windows, the profile directory changes depending on the user that // launched the process (e.g. when launched with elevation). setting the // profile dir on launch ensures it uses the same profile dir is used // no matter how its relaunched. args << "--profile-dir" << getProfileRootForArg(); + +#else + if (m_AppConfig->getCryptoEnabled()) { + args << "--enable-crypto"; + args << "--tls-cert" << m_AppConfig->getTLSCertPath(); + } #endif if ((synergyType() == synergyClient && !clientArgs(args, app)) diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index 9f44a9a75..a4f19c973 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -166,7 +166,6 @@ void SettingsDialog::loadFromConfig() { m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); m_pGroupBoxTLS->setVisible(m_appConfig.getCryptoEnabled()); - #ifdef SYNERGY_ENTERPRISE m_pCheckBoxEnableCrypto->setEnabled(true); @@ -177,9 +176,8 @@ void SettingsDialog::loadFromConfig() { #else - bool isPro = m_appConfig.edition() == kPro; - m_pCheckBoxEnableCrypto->setEnabled(isPro); - m_pLabelProUpgrade->setVisible(!isPro); + m_pCheckBoxEnableCrypto->setEnabled(m_appConfig.isCryptoAvailable()); + m_pLabelProUpgrade->setVisible(!m_appConfig.isCryptoAvailable()); m_pCheckBoxAutoConfig->setChecked(appConfig().autoConfig());