From f1a7977f92df4578891ea54b12a62d6054b16b55 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Mon, 22 Oct 2018 17:24:13 +0200
Subject: [PATCH] Allow client certificates without openssl

We don't use OpenSSL, but only depended on it because QtNetwork didn't
define QSslCertificate without an SSL backend.

I changed that in QtNetwork 5.12, so we only rely on a QtNetwork SSL
backend with older Qt versions.

Task-number: QTBUG-54877
Change-Id: I16f3077235f5c48610597868608ef2e5ca2efa99
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
---
 examples/webenginewidgets/simplebrowser/webpage.cpp         | 4 ++--
 examples/webenginewidgets/simplebrowser/webpage.h           | 2 +-
 src/core/client_cert_select_controller.cpp                  | 4 ++--
 src/core/client_cert_select_controller.h                    | 6 +++---
 .../api/qwebengineclientcertificateselection.cpp            | 4 ++--
 .../api/qwebengineclientcertificateselection.h              | 4 ++--
 src/webenginewidgets/api/qwebenginepage.cpp                 | 4 ++--
 src/webenginewidgets/api/qwebenginepage.h                   | 2 +-
 8 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/examples/webenginewidgets/simplebrowser/webpage.cpp b/examples/webenginewidgets/simplebrowser/webpage.cpp
index ab9dce4b8..e44410284 100644
--- a/examples/webenginewidgets/simplebrowser/webpage.cpp
+++ b/examples/webenginewidgets/simplebrowser/webpage.cpp
@@ -66,7 +66,7 @@ WebPage::WebPage(QWebEngineProfile *profile, QObject *parent)
     connect(this, &QWebEnginePage::featurePermissionRequested, this, &WebPage::handleFeaturePermissionRequested);
     connect(this, &QWebEnginePage::proxyAuthenticationRequired, this, &WebPage::handleProxyAuthenticationRequired);
     connect(this, &QWebEnginePage::registerProtocolHandlerRequested, this, &WebPage::handleRegisterProtocolHandlerRequested);
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
     connect(this, &QWebEnginePage::selectClientCertificate, this, &WebPage::handleSelectClientCertificate);
 #endif
 }
@@ -197,7 +197,7 @@ void WebPage::handleRegisterProtocolHandlerRequested(QWebEngineRegisterProtocolH
 }
 //! [registerProtocolHandlerRequested]
 
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
 void WebPage::handleSelectClientCertificate(QWebEngineClientCertificateSelection selection)
 {
     // Just select one.
diff --git a/examples/webenginewidgets/simplebrowser/webpage.h b/examples/webenginewidgets/simplebrowser/webpage.h
index 0b351ab31..908295894 100644
--- a/examples/webenginewidgets/simplebrowser/webpage.h
+++ b/examples/webenginewidgets/simplebrowser/webpage.h
@@ -69,7 +69,7 @@ private slots:
     void handleFeaturePermissionRequested(const QUrl &securityOrigin, Feature feature);
     void handleProxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *auth, const QString &proxyHost);
     void handleRegisterProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request);
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
     void handleSelectClientCertificate(QWebEngineClientCertificateSelection clientCertSelection);
 #endif
 };
diff --git a/src/core/client_cert_select_controller.cpp b/src/core/client_cert_select_controller.cpp
index 1362322f7..7d08d57c1 100644
--- a/src/core/client_cert_select_controller.cpp
+++ b/src/core/client_cert_select_controller.cpp
@@ -71,7 +71,7 @@ ClientCertSelectController::~ClientCertSelectController()
         m_delegate->ContinueWithCertificate(nullptr, nullptr);
 }
 
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
 
 void ClientCertSelectController::selectNone()
 {
@@ -118,6 +118,6 @@ QVector<QSslCertificate> ClientCertSelectController::certificates() const
     return out;
 }
 
-#endif // QT_CONFIG(ssl)
+#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
 
 QT_END_NAMESPACE
diff --git a/src/core/client_cert_select_controller.h b/src/core/client_cert_select_controller.h
index 4a245c74c..46324ee90 100644
--- a/src/core/client_cert_select_controller.h
+++ b/src/core/client_cert_select_controller.h
@@ -55,7 +55,7 @@
 #include <QtNetwork/qtnetwork-config.h>
 
 #include <QtCore/QUrl>
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
 #include <QtCore/QVector>
 #include <QtNetwork/QSslCertificate>
 #endif
@@ -80,12 +80,12 @@ public:
     ~ClientCertSelectController();
 
     QUrl hostAndPort() const { return m_hostAndPort; }
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
     void selectNone();
     void select(const QSslCertificate &certificate);
 
     QVector<QSslCertificate> certificates() const;
-#endif // QT_CONFIG(ssl)
+#endif
 
 private:
     QUrl m_hostAndPort;
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
index 8d3c8d223..9eca01bbe 100644
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
+++ b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
@@ -39,7 +39,7 @@
 
 #include "qwebengineclientcertificateselection.h"
 
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
 
 #include "client_cert_select_controller.h"
 
@@ -124,4 +124,4 @@ QUrl QWebEngineClientCertificateSelection::host() const
 
 QT_END_NAMESPACE
 
-#endif // QT_CONFIG(ssl)
+#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.h b/src/webenginewidgets/api/qwebengineclientcertificateselection.h
index 15b8a47c6..d451d09ae 100644
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.h
+++ b/src/webenginewidgets/api/qwebengineclientcertificateselection.h
@@ -43,7 +43,7 @@
 #include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
 #include <QtNetwork/qtnetwork-config.h>
 
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
 
 #include <QtCore/qscopedpointer.h>
 #include <QtCore/qvector.h>
@@ -75,6 +75,6 @@ private:
 
 QT_END_NAMESPACE
 
-#endif // QT_CONFIG(ssl)
+#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
 
 #endif // QWEBENGINECLIENTCERTSELECTION_H
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index fbb7c1f9e..953cb4168 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -1677,7 +1677,7 @@ void QWebEnginePagePrivate::allowCertificateError(const QSharedPointer<Certifica
 
 void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller)
 {
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
     Q_Q(QWebEnginePage);
     QWebEngineClientCertificateSelection certSelection(controller);
 
@@ -1687,7 +1687,7 @@ void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSele
 #endif
 }
 
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
 /*!
     \fn void QWebEnginePage::selectClientCertificate(QWebEngineClientCertificateSelection clientCertificateSelection)
     \since 5.12
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 6dd2da21c..69e0ce4a3 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -322,7 +322,7 @@ Q_SIGNALS:
     void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
     void quotaRequested(QWebEngineQuotaRequest quotaRequest);
     void registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request);
-#if QT_CONFIG(ssl)
+#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
     void selectClientCertificate(QWebEngineClientCertificateSelection clientCertSelection);
 #endif
 
-- 
GitLab