diff options
author | Mert Tumer <mert.tumer@collabora.com> | 2022-07-04 19:52:49 +0300 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2023-01-30 22:12:03 +0000 |
commit | 1fb964276c184b0fb052503fe7dbc05bf0331211 (patch) | |
tree | 780afc0573b9407aa1bc2d4b05e1216d2b868e13 /lingucomponent/source/spellcheck | |
parent | ed68634db25103cd7d2adc29f3973f80fbaec324 (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/+/145594
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'lingucomponent/source/spellcheck')
-rw-r--r-- | lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx index a2ad3efdf863..b868e4744ac7 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,12 @@ 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; } |