diff -urN libreoffice-5.4.2.2-orig/Repository.mk libreoffice-5.4.2.2/Repository.mk
--- libreoffice-5.4.2.2-orig/Repository.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/Repository.mk	2017-11-08 22:15:11 +0900
@@ -375,7 +375,7 @@
 	hyphen \
     icg \
 	$(if $(ENABLE_JAVA),jdbc) \
-	ldapbe2 \
+	$(if $(ENABLE_NSS),ldapbe2) \
 	localebe1 \
 	log \
 	lng \
@@ -621,9 +621,11 @@
 	ucphier1 \
 	ucppkg1 \
 	unopkgapp \
-	xmlsecurity \
-	xsec_fw \
-	xsec_xmlsec \
+	$(if $(ENABLE_NSS), \
+		xmlsecurity \
+		xsec_fw \
+		xsec_xmlsec \
+	) \
 	xstor \
 	$(if $(filter $(OS),MACOSX), \
 		macab1 \
diff -urN libreoffice-5.4.2.2-orig/RepositoryExternal.mk libreoffice-5.4.2.2/RepositoryExternal.mk
--- libreoffice-5.4.2.2-orig/RepositoryExternal.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/RepositoryExternal.mk	2017-11-08 21:06:24 +0900
@@ -921,6 +921,8 @@
 endif # SYSTEM_LIBXSLT
 
 
+ifeq ($(ENABLE_NSS),TRUE)
+
 ifneq ($(SYSTEM_XMLSEC),)
 
 define gb_LinkTarget__use_xmlsec
@@ -949,6 +951,8 @@
 
 endif # SYSTEM_XMLSEC
 
+endif # ENABLE_NSS
+
 ifneq ($(SYSTEM_LIBLANGTAG),)
 
 define gb_LinkTarget__use_liblangtag
@@ -3259,7 +3263,7 @@
 
 gb_ExternalProject__use_nss3:=
 
-ifeq ($(OS),ANDROID)
+ifneq ($(ENABLE_NSS),TRUE)
 
 gb_LinkTarget__use_nss3:=
 gb_LinkTarget__use_plc4:=
@@ -3386,6 +3390,8 @@
 
 endif # ENABLE_BREAKPAD
 
+ifeq ($(ENABLE_NSS),TRUE)
+
 ifneq ($(SYSTEM_GPGMEPP),)
 
 gb_ExternalProject__use_gpgmepp:=
@@ -3445,6 +3451,8 @@
 
 endif
 
+endif # ENABLE_NSS
+
 ifeq ($(ENABLE_GLTF),TRUE)
 
 ifneq ($(SYSTEM_LIBGLTF),TRUE)
diff -urN libreoffice-5.4.2.2-orig/configure.ac libreoffice-5.4.2.2/configure.ac
--- libreoffice-5.4.2.2-orig/configure.ac	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/configure.ac	2017-11-08 19:44:10 +0900
@@ -1473,6 +1473,12 @@
         [MACOSX only: on MacOSX pkg-config can cause trouble. by default if one is found in the PATH, an error is issued. This flag turn that error into a warning.]),
 )
 
+AC_ARG_ENABLE(nss,
+    AS_HELP_STRING([--disable-nss],
+        [Disable using NSS for encryption. If disabled, components
+         will either use OpenSSL or GNUTLS.]),
+,enable_nss=yes)
+
 AC_ARG_ENABLE(openssl,
     AS_HELP_STRING([--disable-openssl],
         [Disable using libssl/libcrypto from OpenSSL. If disabled,
@@ -7824,7 +7830,9 @@
 dnl ===================================================================
 dnl Check for system xmlsec
 dnl ===================================================================
-libo_CHECK_SYSTEM_MODULE([xmlsec], [XMLSEC], [xmlsec1-nss >= 1.2.24])
+if test "$enable_nss" != "no"; then
+    libo_CHECK_SYSTEM_MODULE([xmlsec], [XMLSEC], [xmlsec1-nss >= 1.2.24])
+fi
 
 AC_MSG_CHECKING([whether to enable Embedded OpenType support])
 if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_eot" = "yes"; then
@@ -8919,7 +8927,7 @@
 dnl ===================================================================
 dnl Check for system NSS
 dnl ===================================================================
-if test $_os != iOS -a $_os != Android -a "$enable_fuzzers" != "yes"; then
+if test $_os != iOS -a $_os != Android -a "$enable_fuzzers" != "yes" -a "$enable_nss" != "no"; then
     libo_CHECK_SYSTEM_MODULE([nss],[NSS],[nss >= 3.9.3 nspr >= 4.8])
     AC_DEFINE(HAVE_FEATURE_NSS)
     ENABLE_NSS="TRUE"
@@ -10409,7 +10417,7 @@
 AC_SUBST(ENABLE_PDFIUM)
 
 SYSTEM_GPGMEPP=
-if test "$_os" = "Linux"; then
+if test "$_os" = "Linux" -a "$enable_nss" != "no"; then
     dnl ===================================================================
     dnl Check for system gpgme
     dnl ===================================================================
diff -urN libreoffice-5.4.2.2-orig/extensions/Module_extensions.mk libreoffice-5.4.2.2/extensions/Module_extensions.mk
--- libreoffice-5.4.2.2-orig/extensions/Module_extensions.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/extensions/Module_extensions.mk	2017-11-08 19:58:35 +0900
@@ -21,10 +21,15 @@
 	UIConfig_scanner \
 ))
 
+ifeq ($(ENABLE_NSS),TRUE)
+$(eval $(call gb_Module_add_targets,extensions,\
+	Library_ldapbe2 \
+))
+endif
+
 ifneq ($(filter-out IOS ANDROID,$(OS)),)
 $(eval $(call gb_Module_add_targets,extensions,\
 	Library_abp \
-	Library_ldapbe2 \
 	Library_log \
 	Library_scn \
 ))
diff -urN libreoffice-5.4.2.2-orig/postprocess/Rdb_services.mk libreoffice-5.4.2.2/postprocess/Rdb_services.mk
--- libreoffice-5.4.2.2-orig/postprocess/Rdb_services.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/postprocess/Rdb_services.mk	2017-11-08 19:58:35 +0900
@@ -301,7 +301,7 @@
 	desktop/source/offacc/offacc \
 	$(if $(ENABLE_HEADLESS),,desktop/source/splash/spl) \
 	extensions/source/abpilot/abp \
-	extensions/source/config/ldap/ldapbe2 \
+	$(if $(ENABLE_NSS),extensions/source/config/ldap/ldapbe2) \
 	extensions/source/logging/log \
 	extensions/source/resource/res \
 	extensions/source/scanner/scn \
diff -urN libreoffice-5.4.2.2-orig/scp2/InstallModule_ooo.mk libreoffice-5.4.2.2/scp2/InstallModule_ooo.mk
--- libreoffice-5.4.2.2-orig/scp2/InstallModule_ooo.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/scp2/InstallModule_ooo.mk	2017-11-09 07:01:05 +0900
@@ -21,6 +21,7 @@
 $(eval $(call gb_InstallModule_define_if_set,scp2/ooo,\
 	ENABLE_SYSTRAY_GTK \
 	ENABLE_MACOSX_SANDBOX \
+	ENABLE_NSS \
 	ENABLE_ONLINE_UPDATE \
 	SYSTEM_CURL \
 	SYSTEM_HSQLDB \
diff -urN libreoffice-5.4.2.2-orig/scp2/source/ooo/file_ooo.scp libreoffice-5.4.2.2/scp2/source/ooo/file_ooo.scp
--- libreoffice-5.4.2.2-orig/scp2/source/ooo/file_ooo.scp	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/scp2/source/ooo/file_ooo.scp	2017-11-09 08:14:09 +0900
@@ -175,7 +175,9 @@
 UI_FILELIST(uui, "UIConfig/uui.filelist")
 UI_FILELIST(vcl, "UIConfig/vcl.filelist")
 UI_FILELIST(writerperfect, "UIConfig/writerperfect.filelist")
+#ifdef ENABLE_NSS
 UI_FILELIST(xmlsec, "UIConfig/xmlsec.filelist")
+#endif
 
 UI_FILELIST_ALL_LANG(basicide, modules/BasicIDE)
 UI_FILELIST_ALL_LANG(cui, cui)
@@ -203,7 +205,9 @@
 UI_FILELIST_ALL_LANG(swriter, modules/swriter)
 UI_FILELIST_ALL_LANG(uui, uui)
 UI_FILELIST_ALL_LANG(vcl, vcl)
+#ifdef ENABLE_NSS
 UI_FILELIST_ALL_LANG(xmlsec, xmlsec)
+#endif
 
 #if defined UNX && ! defined MACOSX
 
diff -urN libreoffice-5.4.2.2-orig/scp2/source/ooo/file_resource_ooo.scp libreoffice-5.4.2.2/scp2/source/ooo/file_resource_ooo.scp
--- libreoffice-5.4.2.2-orig/scp2/source/ooo/file_resource_ooo.scp	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/scp2/source/ooo/file_resource_ooo.scp	2017-11-09 09:19:06 +0900
@@ -97,7 +97,9 @@
 
 STD_RES_FILE( gid_File_Res_AVMedia, avmedia )
 
+#ifdef ENABLE_NSS
 STD_RES_FILE( gid_File_Res_XMLSecurity, xmlsec )
+#endif
 
 STD_RES_FILE( gid_File_Res_Upd, upd )
 
