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-24 17:14:10 +0200
commitd065d61ce7735337cca0450d7b37fab6fde72de3 (patch)
tree1cee0bbb9f9808ba97f7428d90a959572ac20855
parent20ea603bcc2dda0355dea19f86e02854df8286ba (diff)
allow an exemption to be made for a specific host
Change-Id: Ie423df7839e793a9c07561efb56d5649876947ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169118 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 dec02b7c3103..6d19015f981f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2794,6 +2794,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 2cf403115cfe..2997eacfa32c 100644
--- a/tools/source/inet/hostfilter.cxx
+++ b/tools/source/inet/hostfilter.cxx
@@ -13,6 +13,7 @@
namespace
{
static std::regex g_AllowedHostsRegex("");
+static OUString g_ExceptVerifyHost;
static bool g_AllowedHostsSet = false;
}
@@ -31,4 +32,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 58ebc35cb6af..f5829df28a40 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -696,6 +696,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() {}