From a9ef2ecb1f1941a9295c58b63987565e6d3518cb Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Thu, 3 Aug 2017 14:09:37 +0200
Subject: [PATCH] Move NSS certificate handling configuration to configure.json

Change-Id: Ibae2b8ebb90e79ff8337d994b2234eed5e230dcc
Reviewed-by: Viktor Engelmann <viktor.engelmann@qt.io>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
---
 configure.json                 | 20 ++++++++++++++++++++
 mkspecs/features/configure.prf | 11 +----------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/configure.json b/configure.json
index c4d00ffcc..b291e6645 100644
--- a/configure.json
+++ b/configure.json
@@ -12,6 +12,7 @@
             "ffmpeg": { "type": "enum", "name": "system-ffmpeg", "values": { "system": "yes", "qt": "no" } },
             "opus": { "type": "enum", "name": "system-opus", "values": { "system": "yes", "qt": "no" } },
             "webp": { "type": "enum", "name": "system-webp", "values": { "system": "yes", "qt": "no" } },
+            "nss-certificate-handling": "boolean",
             "pepper-plugins": "boolean",
             "printing-and-pdf": "boolean",
             "proprietary-codecs": "boolean",
@@ -58,6 +59,12 @@
             "sources": [
                 { "type": "pkgConfig", "args": "libwebp libwebpdemux" }
             ]
+        },
+        "nss": {
+            "label": "NSS",
+            "sources": [
+                { "type": "pkgConfig", "args": "nss" }
+            ]
         }
     },
 
@@ -171,6 +178,14 @@
             "autoDetect": "!features.embedded",
             "output": [ "privateFeature" ]
         },
+        "nss-certificate-handling": {
+            "label": "NSS certificate handling",
+            "purpose": "Use NSS to handle certificates instead of BoringSSL. Recommended on Linux.",
+            "section": "WebEngine",
+            "condition": "config.unix && !config.darwin",
+            "autoDetect": "libs.nss",
+            "output": [ "privateFeature" ]
+        },
         "system-webp": {
             "label": "libwebp and libwebpdemux",
             "autoDetect": "config.unix",
@@ -252,6 +267,11 @@
                     "args": "pulseaudio",
                     "condition": "config.unix"
                 },
+                {
+                    "type": "feature",
+                    "args": "nss-certificate-handling",
+                    "condition": "config.unix && !config.darwin"
+                },
                 {
                    "section": "System libraries",
                    "condition": "config.unix",
diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf
index 48a2f0f96..87e43733d 100644
--- a/mkspecs/features/configure.prf
+++ b/mkspecs/features/configure.prf
@@ -51,6 +51,7 @@ defineTest(runConfigure) {
         qtConfig(system-opus): WEBENGINE_CONFIG += use_system_opus
         qtConfig(system-ffmpeg): WEBENGINE_CONFIG += use_system_ffmpeg
         qtConfig(system-icu): WEBENGINE_CONFIG += use_system_icu
+        qtConfig(nss-certificate-handling): WEBENGINE_CONFIG += use_nss
         !contains(WEBENGINE_CONFIG, use_system_libwebp): WEBENGINE_CONFIG += use_bundled_libwebp
         !contains(WEBENGINE_CONFIG, use_system_opus): WEBENGINE_CONFIG += use_bundled_opus
         !contains(WEBENGINE_CONFIG, use_system_ffmpeg): WEBENGINE_CONFIG += use_bundled_ffmpeg
@@ -135,9 +136,6 @@ defineTest(runConfigure) {
             log("System snappy not found. Using Chromium's copy.$${EOL}")
             WEBENGINE_CONFIG += use_bundled_snappy
         }
-
-        packagesExist(nss): WEBENGINE_CONFIG += use_nss
-        else: log("System NSS not found, BoringSSL will be used.$${EOL}")
     }
 
     win32 {
@@ -207,13 +205,6 @@ defineTest(runConfigure) {
     } else {
         log("  Geolocation ........................ Not enabled         (Requires Qt Positioning module)$${EOL}")
     }
-    unix:!darwin {
-        use?(nss) {
-            log("  Certificate handling ............... Using system NSS$${EOL}")
-        } else {
-            log("  Certificate handling ............... Using bundled BoringSSL$${EOL}")
-        }
-    }
     osx {
         use?(native_spellchecker) {
             log("Native Spellchecker .............. Enabled$${EOL}")
-- 
GitLab