summaryrefslogtreecommitdiff
path: root/lingucomponent
diff options
context:
space:
mode:
authorMert Tumer <mert.tumer@collabora.com>2022-07-04 19:52:49 +0300
committerAndras Timar <andras.timar@collabora.com>2023-01-28 10:55:04 +0100
commit53d0c957d3bc178248c6bead508622098fb03050 (patch)
treed6de8d97fd3025fae2ffb8544f11f52904f2346f /lingucomponent
parent88a4096ab1fafa3cb0fdb1638b946b4fb4a76ecc (diff)
Added option to disable ssl verification for languagetool
This will allow to use self-signed certificates with local run languagetool APIs Signed-off-by: Mert Tumer <mert.tumer@collabora.com> Change-Id: I2bda575fa6174dfc0f6c24da45267ee732643db6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136811 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145604 Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'lingucomponent')
-rw-r--r--lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx
index a2ad3efdf863..1dce1845fc43 100644
--- a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx
+++ b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx
@@ -41,6 +41,9 @@
#include <tools/long.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <unotools/lingucfg.hxx>
+#include <osl/mutex.hxx>
+#include <sal/log.hxx>
using namespace osl;
using namespace com::sun::star;
@@ -341,8 +344,12 @@ std::string LanguageToolGrammarChecker::makeHttpRequest(std::string_view aURL, H
(void)curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, WriteCallback);
(void)curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, static_cast<void*>(&response_body));
- (void)curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, false);
- (void)curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, false);
+ // allow unknown or self-signed certificates
+ if (rLanguageOpts.getSSLVerification() == false)
+ {
+ (void)curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, false);
+ (void)curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, false);
+ }
(void)curl_easy_setopt(curl.get(), CURLOPT_TIMEOUT, CURL_TIMEOUT);
if (method == HTTP_METHOD::HTTP_POST)
@@ -359,8 +366,11 @@ std::string LanguageToolGrammarChecker::makeHttpRequest(std::string_view aURL, H
}
}
- /*CURLcode cc = */
- (void)curl_easy_perform(curl.get());
+ CURLcode cc = curl_easy_perform(curl.get());
+ if (cc != CURLE_OK)
+ {
+ SAL_WARN("languagetool", "CURL request returned with error: " << static_cast<sal_Int32>(cc));
+ }
curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &nStatusCode);
return response_body;
}