summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-06-04 21:17:59 +0100
committerAndras Timar <andras.timar@collabora.com>2024-06-25 22:59:47 +0200
commit05c7fada04418a181b067fe92c39a5442cd9d4d4 (patch)
tree40ae26945865fff7bfe67df49117483d543ad101
parent6f84f77d9d49dbfecd8a9e212aba5bde1455797d (diff)
allow an exemption to be made for a specific host
Change-Id: Ie423df7839e793a9c07561efb56d5649876947ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168826 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--desktop/source/lib/init.cxx3
-rw-r--r--include/tools/hostfilter.hxx4
-rw-r--r--tools/source/inet/hostfilter.cxx11
-rw-r--r--ucb/source/ucp/webdav-curl/CurlSession.cxx5
4 files changed, 23 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index eae08a12889e..ee2ac3508b08 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2843,6 +2843,9 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
OutputDevice::StartTrackingFontMappingUse();
+ if (const char* pExemptVerifyHost = ::getenv("LOK_EXEMPT_VERIFY_HOST"))
+ HostFilter::setExemptVerifyHost(OUString(pExemptVerifyHost, strlen(pExemptVerifyHost), RTL_TEXTENCODING_UTF8));
+
const int nThisDocumentId = nDocumentIdCounter++;
SfxViewShell::SetCurrentDocId(ViewShellDocId(nThisDocumentId));
uno::Reference<lang::XComponent> xComponent = xComponentLoader->loadComponentFromURL(
diff --git a/include/tools/hostfilter.hxx b/include/tools/hostfilter.hxx
index afbf885b0cb4..ca2d91355986 100644
--- a/include/tools/hostfilter.hxx
+++ b/include/tools/hostfilter.hxx
@@ -21,6 +21,10 @@ public:
static void setAllowedHostsRegex(const char* sAllowedRegex);
static bool isForbidden(const OUString& rHost);
+
+ static void setExemptVerifyHost(const OUString& rExemptVerifyHost);
+
+ static bool isExemptVerifyHost(const std::u16string_view rHost);
};
#endif
diff --git a/tools/source/inet/hostfilter.cxx b/tools/source/inet/hostfilter.cxx
index 5bc63d42cfb7..e13e3d66cab6 100644
--- a/tools/source/inet/hostfilter.cxx
+++ b/tools/source/inet/hostfilter.cxx
@@ -11,6 +11,7 @@
#include <regex>
static std::regex g_AllowedHostsRegex("");
+static OUString g_ExceptVerifyHost;
static bool g_AllowedHostsSet = false;
void HostFilter::setAllowedHostsRegex(const char* sAllowedRegex)
@@ -28,4 +29,14 @@ bool HostFilter::isForbidden(const OUString& rHost)
return !std::regex_match(rHost.toUtf8().getStr(), g_AllowedHostsRegex);
}
+void HostFilter::setExemptVerifyHost(const OUString& rExemptVerifyHost)
+{
+ g_ExceptVerifyHost = rExemptVerifyHost;
+}
+
+bool HostFilter::isExemptVerifyHost(const std::u16string_view rHost)
+{
+ return rHost == g_ExceptVerifyHost;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index a80c19f6d690..7089dcacdbdb 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -694,6 +694,11 @@ CurlSession::CurlSession(uno::Reference<uno::XComponentContext> xContext,
rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_FORBID_REUSE, 1L);
assert(rc == CURLE_OK);
}
+ if (HostFilter::isExemptVerifyHost(m_URI.GetHost()))
+ {
+ rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_SSL_VERIFYHOST, 0L);
+ assert(rc == CURLE_OK);
+ }
}
CurlSession::~CurlSession() {}