desktop/source/lib/init.cxx |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

New commits:
commit 15fad73dd274f604f24a1c172c1b9e6e1668cfd8
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Dec 8 20:42:42 2021 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed Dec 15 13:57:07 2021 +0100

    lokit: add env. var to set the certificate database dir
    
    This adds to LOKit a way to set the certificate database dir with
    a env. var. - LO_CERTIFICATE_DATABASE_PATH, which is used for
    signing and encrypting of documents.
    
    Change-Id: Ieb7725d41893212d962c8b9e32f9607d0ba10397
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126553
    Tested-by: Andras Timar <andras.ti...@collabora.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126853
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 19b5578d704e..5e82c3d379ff 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -183,6 +183,7 @@
 
 #include "lokinteractionhandler.hxx"
 #include "lokclipboard.hxx"
+#include <officecfg/Office/Common.hxx>
 #include <officecfg/Office/Impress.hxx>
 
 using namespace css;
@@ -6267,6 +6268,25 @@ static void activateNotebookbar(const OUString& rApp)
         aAppNode.commit();
     }
 }
+void setCertificateDir()
+{
+    const char* pEnvVarString = ::getenv("LO_CERTIFICATE_DATABASE_PATH");
+    if (pEnvVarString)
+    {
+        OUString aCertificateDatabasePath = OStringToOUString(pEnvVarString, 
RTL_TEXTENCODING_UTF8);
+        try
+        {
+            std::shared_ptr<comphelper::ConfigurationChanges> 
pBatch(comphelper::ConfigurationChanges::create());
+            
officecfg::Office::Common::Security::Scripting::CertDir::set(aCertificateDatabasePath,
 pBatch);
+            
officecfg::Office::Common::Security::Scripting::ManualCertDir::set(aCertificateDatabasePath,
 pBatch);
+            pBatch->commit();
+        }
+        catch (uno::Exception const& rException)
+        {
+            SAL_WARN("lok", "Failed to set the NSS certificate database 
directory: " << rException.Message);
+        }
+    }
+}
 
 static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const 
char* pUserProfileUrl)
 {
@@ -6575,6 +6595,8 @@ static int lo_initialize(LibreOfficeKit* pThis, const 
char* pAppPath, const char
     }
 #endif
 
+    setCertificateDir();
+
     if (bNotebookbar)
     {
         activateNotebookbar("Writer");

Reply via email to