how to disable certificate validation

Nov 18, 2015 at 4:18 PM
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
Coordinator
Nov 18, 2015 at 8:15 PM
Nov 19, 2015 at 2:28 PM
I am using Casablanca 2.4 with visual studio 2012
Coordinator
Nov 19, 2015 at 5:53 PM
Could you please try using version 2.6? We no longer support VS2012 as well, so consider using VS2015 (available for free at https://www.visualstudio.com/free).
Nov 23, 2015 at 12:54 AM
I just uninstalled casablanca 2.4.0 and reinstalled it again and it worked fine. Don't know what was the problem. Anyways since it is working fine now, I am moving on.
Marked as answer by roschuma on 11/23/2015 at 1:04 PM