1

I have a c++ application that sending data using http with WinHttpClient and i want to start sanding https

bool ret = false;
WinHttpClient client(wstring(url.begin(), url.end()));

ret = client.SetAdditionalDataToSend((BYTE *)data.c_str(), (unsigned int)data.length());

if (ret)
{
    // Set request headers.
    wchar_t szSize[50] = L"";
    swprintf_s(szSize, L"%d", data.size());
    wstring headers = L"Content-Length: ";
    headers += szSize;
    headers += L"\r\nContent-Type: application/x-www-form-urlencoded\r\n";
    string apiVersion = ...;
    headers += L"\r\nAccept-Version: " + wstring(apiVersion.begin(), apiVersion.end()) + L"\r\n";
    ret = client.SetAdditionalRequestHeaders(headers);
    client.SetUserAgent(L"..." + to_wstring(...));
}

// Send http post request.
if (ret) ret = client.SendHttpRequest(L"POST");

i have read that i need to add

client.SetRequireValidSslCertificates(false);

after i create the client, but when i tried noting change so the question it how to send it using https?

0 Answers0