From 1fb964276c184b0fb052503fe7dbc05bf0331211 Mon Sep 17 00:00:00 2001 From: Mert Tumer Date: Mon, 4 Jul 2022 19:52:49 +0300 Subject: 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 Change-Id: I2bda575fa6174dfc0f6c24da45267ee732643db6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136811 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145594 Tested-by: Jenkins Reviewed-by: Henry Castro --- .../spellcheck/languagetool/languagetoolimp.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'lingucomponent') 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 #include #include +#include +#include +#include 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(&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(cc)); + } curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &nStatusCode); return response_body; } -- cgit