Fix #3066 by make sure cert location is handled in main thread

This commit is contained in:
Benau
2018-07-07 12:33:30 +08:00
parent 21ccf587c3
commit efd20966e4
2 changed files with 11 additions and 4 deletions

View File

@@ -30,6 +30,7 @@
namespace Online
{
std::string HTTPRequest::m_cert_location;
const std::string API::USER_PATH = "user/";
const std::string API::SERVER_PATH = "server/";
@@ -94,6 +95,11 @@ namespace Online
m_parameters = "";
m_curl_code = CURLE_OK;
m_progress.setAtomic(0);
if (m_cert_location.empty())
{
m_cert_location =
file_manager->getAsset("addons.supertuxkart.net.pem");
}
} // init
// ------------------------------------------------------------------------
@@ -179,13 +185,13 @@ namespace Online
chunk = curl_slist_append(chunk, "Host: addons.supertuxkart.net");
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER, chunk);
CURLcode error = curl_easy_setopt(m_curl_session, CURLOPT_CAINFO,
file_manager->getAsset("addons.supertuxkart.net.pem").c_str());
m_cert_location.c_str());
if (error != CURLE_OK)
{
Log::error("HTTPRequest", "Error setting CAINFO to '%s'",
file_manager->getAsset("addons.supertuxkart.net.pem").c_str());
Log::error("HTTPRequest", "Error %d: '%s'.", error,
curl_easy_strerror(error));
m_cert_location.c_str());
Log::error("HTTPRequest", "Error: '%s'.", error,
curl_easy_strerror(error));
}
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYPEER, 1L);
#ifdef __APPLE__

View File

@@ -71,6 +71,7 @@ namespace Online
/** String to store the received data in. */
std::string m_string_buffer;
static std::string m_cert_location;
protected:
virtual void prepareOperation() OVERRIDE;
virtual void operation() OVERRIDE;