user3664223
user3664223

Reputation: 337

WinHttpSetOption for HTTPS only

I wanted send request only https, not for http now options should I put to restrict https only. Not able to understand which Flags dwFlags should removed to disallow HTTP.

      DWORD dwFlags = SECURITY_FLAG_IGNORE_UNKNOWN_CA |
                  SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE |
                  SECURITY_FLAG_IGNORE_CERT_CN_INVALID |
                  SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;

  if (WinHttpSetOption(hRequest,
                       WINHTTP_OPTION_SECURITY_FLAGS,
                       &dwFlags,
                       sizeof(dwFlags))) {

     bResults = WinHttpSendRequest(hRequest,
                                   WINHTTP_NO_ADDITIONAL_HEADERS,
                                   0, WINHTTP_NO_REQUEST_DATA, 0,
                                   0, 0);

Thanks,

Upvotes: 1

Views: 2197

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596156

To send a request using HTTPS, you need to specify the WINHTTP_FLAG_SECURE flag when calling WinHttpOpenRequest():

Uses secure transaction semantics. This translates to using Secure Sockets Layer (SSL)/Transport Layer Security (TLS).

HTTPS is HTTP over SSL/TLS.

Upvotes: 3

Related Questions