Skip to content

Commit

Permalink
Gives ANSI path to curl CURLOPT_CAINFO
Browse files Browse the repository at this point in the history
  • Loading branch information
RipleyTom committed Mar 26, 2020
1 parent e817790 commit 7dfefde
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion rpcs3/rpcs3qt/curl_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,25 @@ curl_handle::curl_handle(QObject* parent) : QObject(parent)
#ifdef _WIN32
// This shouldn't be needed on linux
const std::string path_to_cert = Emulator::GetEmuDir() + "cacert.pem";
curl_easy_setopt(m_curl, CURLOPT_CAINFO, path_to_cert.c_str());
std::vector<wchar_t> buf_wide, buf_short;
std::vector<char> buf_final;

// Converts the utf-8 path to wide char
auto tmp_size = MultiByteToWideChar(CP_UTF8, 0, path_to_cert.c_str(), -1, nullptr, 0);
buf_wide.resize(tmp_size);
MultiByteToWideChar(CP_UTF8, 0, path_to_cert.c_str(), -1, buf_wide.data(), tmp_size);

// Get the short path from the wide char path(short path should only contain ansi characters)
tmp_size = GetShortPathNameW(buf_wide.data(), nullptr, 0);
buf_short.resize(tmp_size);
GetShortPathNameW(buf_wide.data(), buf_short.data(), tmp_size);

// Convert wide char to ansi
tmp_size = WideCharToMultiByte(CP_ACP, 0, buf_short.data(), -1, nullptr, 0, nullptr, nullptr);
buf_final.resize(tmp_size);
WideCharToMultiByte(CP_ACP, 0, buf_short.data(), -1, buf_final.data(), tmp_size, nullptr, nullptr);

curl_easy_setopt(m_curl, CURLOPT_CAINFO, buf_final.data());
#endif
}

Expand Down

0 comments on commit 7dfefde

Please sign in to comment.