http_client always fails when server supports (but not requires) client certificates
I want to use http_client to send WNS notifications from an IoT device, but for now I'm developing the code on a windows 10 machine so I can properly debug everything. I can properly authenticate with WNS but when I try to send a notification I'm getting a http_exception ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED (12044). The same requests header/body goes through cleanly when issued from C# code without having to do anything about client certificates, so I believe your implementation has a bug.
After some trial and error I figured out that I could disable client certificates explicitely with the following code:
web::http::client::http_client_config config;
config.set_nativehandle_options([](web::http::client::native_handle handle) {
WinHttpSetOption(handle, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, WINHTTP_NO_CLIENT_CERT_CONTEXT, 0);
});
This allows the request to go through cleanly. Since your http_client class does not support client certificates out of the box I believe you should configure this by default and not require callers to have to configure every request manually.
You made my day ;)