diff options
author | Mert Tumer <mert.tumer@collabora.com> | 2022-07-04 19:52:49 +0300 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-07-05 11:28:39 +0200 |
commit | 3a7a58d8b86bffed074bee56ad96fd3e673ef040 (patch) | |
tree | ac8d2b094ff6da3667a5018cd2a2c03cc8454889 /lingucomponent | |
parent | c1743dc6f610db557de1a4fd31ce8c0f090f4c52 (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>
Diffstat (limited to 'lingucomponent')
-rw-r--r-- | lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx index 5479e67e82c4..da0d133a6965 100644 --- a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx +++ b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/uno/Any.hxx> #include <unotools/lingucfg.hxx> #include <osl/mutex.hxx> +#include <sal/log.hxx> using namespace osl; using namespace com::sun::star; @@ -332,8 +333,12 @@ std::string LanguageToolGrammarChecker::makeHttpRequest(std::string_view aURL, H curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, static_cast<void*>(&response_body)); - curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, false); - curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, false); + // allow unknown or self-signed certificates + if (rLanguageOpts.getSSLVerification() == false) + { + curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, false); + curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, false); + } curl_easy_setopt(curl.get(), CURLOPT_TIMEOUT, CURL_TIMEOUT); if (method == HTTP_METHOD::HTTP_POST) @@ -350,8 +355,11 @@ std::string LanguageToolGrammarChecker::makeHttpRequest(std::string_view aURL, H } } - /*CURLcode cc = */ - 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; } |