- 1 year ago
what the equivalent of WINHTTP_NO_CLIENT_CERT_CONTEXT under Wininet?
In the WinINet API, the equivalent of WINHTTP_NO_CLIENT_CERT_CONTEXT
from the WinHTTP API is NULL
. When using WinINet, you can set the client certificate context parameter to NULL
to indicate that no client certificate is being provided.
Here's an example of how you can use NULL
as the equivalent of WINHTTP_NO_CLIENT_CERT_CONTEXT
in WinINet:
cpp#include <windows.h>
#include <wininet.h>
// ...
HINTERNET hInternet = InternetOpen(L"MyApp", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
HINTERNET hConnect = InternetOpenUrl(hInternet, L"http://example.com", NULL, 0, INTERNET_FLAG_SECURE, 0);
INTERNET_OPTION_CLIENT_CERT_CONTEXT option = { 0 };
option.hInternet = hConnect;
option.dwFlags = INTERNET_FLAG_IGNORE_CERT_CN_INVALID | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID;
option.pCertContext = NULL; // Equivalent to WINHTTP_NO_CLIENT_CERT_CONTEXT
InternetSetOption(hConnect, INTERNET_OPTION_CLIENT_CERT_CONTEXT, &option, sizeof(option));
// ...
In the example above, the INTERNET_OPTION_CLIENT_CERT_CONTEXT
option is used to set the client certificate context for an HTTPS request. By setting option.pCertContext
to NULL
, you indicate that no client certificate context is provided, which is equivalent to WINHTTP_NO_CLIENT_CERT_CONTEXT
in the WinHTTP API.
Note that you need to include the necessary header files (windows.h
and wininet.h
) and link against the appropriate library (wininet.lib
) when using WinINet functions.
Make sure to handle any errors and check the return values of the WinINet functions for proper error handling and resource cleanup in your specific code.