From 6695cf2a3934f4a175ab141f9c9d93259f2e7664 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 15 Jan 2019 10:01:01 +0100 Subject: [PATCH] #3965 HoloLens : Add flag in preferences to disable ssl verification --- ApplicationCode/Application/RiaPreferences.cpp | 8 ++++++-- ApplicationCode/Application/RiaPreferences.h | 2 ++ .../HoloLensCommands/RicHoloLensRestClient.cpp | 11 +++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 5970ac4386..fb8a9c60d8 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -109,6 +109,9 @@ RiaPreferences::RiaPreferences(void) m_holoLensExportFolder.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); m_holoLensExportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); + CAF_PDM_InitField(&holoLensDisableCertificateVerification, "holoLensDisableCertificateVerification", false, "Disable SSL Certificate Verification (HoloLens)", "", "", ""); + holoLensDisableCertificateVerification.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", ""); m_readerSettings = new RifReaderSettings; @@ -154,7 +157,8 @@ void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt field == &m_appendFieldKeywordToToolTipText || field == &m_showTestToolbar || field == &m_includeFractureDebugInfoFile || - field == &showLasCurveWithoutTvdWarning) + field == &showLasCurveWithoutTvdWarning || + field == &holoLensDisableCertificateVerification) { caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast(attribute); if (myAttr) @@ -194,10 +198,10 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& viewsGroup->add(&useShaders); viewsGroup->add(&showHud); - caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup("Other"); otherGroup->add(&ssihubAddress); otherGroup->add(&showLasCurveWithoutTvdWarning); + otherGroup->add(&holoLensDisableCertificateVerification); } else if (uiConfigName == m_tabNames[1]) diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index eba31f902e..f83575d9f6 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -87,6 +87,8 @@ public: // Pdm Fields caf::PdmField summaryImportMode; caf::PdmField gridImportMode; + caf::PdmField holoLensDisableCertificateVerification; + protected: void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensRestClient.cpp b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensRestClient.cpp index f8984b18bc..2489e4e048 100644 --- a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensRestClient.cpp +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensRestClient.cpp @@ -18,6 +18,9 @@ #include "RicHoloLensRestClient.h" +#include "RiaApplication.h" +#include "RiaPreferences.h" + #include "cvfBase.h" #include "cvfTrace.h" @@ -76,6 +79,7 @@ void RicHoloLensRestClient::createSession(const QByteArray& sessionPinCode) request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded")); request.setRawHeader("PinCode", sessionPinCode); + #ifdef EXPERIMENTAL_SSL_SUPPORT // NOTE !!! // Apparently something like this is currently needed in order to get SSL/HTTPS going @@ -86,8 +90,11 @@ void RicHoloLensRestClient::createSession(const QByteArray& sessionPinCode) // Needed this one to be able to connect to sharing server sslConf.setProtocol(QSsl::AnyProtocol); - // !!MUST!! remove this code in production - sslConf.setPeerVerifyMode(QSslSocket::VerifyNone); + bool disableCertificateVerification = RiaApplication::instance()->preferences()->holoLensDisableCertificateVerification(); + if (disableCertificateVerification) + { + sslConf.setPeerVerifyMode(QSslSocket::VerifyNone); + } request.setSslConfiguration(sslConf); #endif