0

I am trying to do a POST on a server using the C++ Rest SDK. It works fine if the Server is set in http, however if the server is set to https, then the code fails with this error

Error exception:EinHttpSendRequest: 12175: A security error occured

I assume that this is because of the certificate validation and to bypass it I set false to set_validate_certificates. But it still gives me the same error.

This is my code.

wstring baseUrl = L"https://167.199.104.41:8044";
    http_client_config config;
    config.set_validate_certificates(false);


    http_client httpClient(baseUrl, config);



    try
    {
        http_request req(methods::POST);
        req.set_request_uri(L"/api/config/%5Bget%5D");
        req.set_body("[\"pool/test/url/server\",\"pool/test/url/instance\"]", "application/json");


        http_response httpResponse = httpClient.request(req).get();

        http::status_code st = httpResponse.status_code();

        if(httpResponse.status_code() == status_codes::OK)
        {
            wstring output = httpResponse.extract_string().get();
            wcout << output << endl;
        }
       }
       catch (const std::exception &e)
       {
         printf("Error exception:%s\n", e.what());
       }

Please guide.

Thanks Sunil

S_R
  • 493
  • 1
  • 9
  • 22

2 Answers2

0

This appears to be rectified in 2.6.0 on NuGet.org

https://www.nuget.org/packages/cpprestsdk.v120.windesktop.msvcstl.dyn.rt-dyn/

0

I just uninstalled casablanca 2.4.0 and then re-installed it again, and it worked for me.

S_R
  • 493
  • 1
  • 9
  • 22