Fix DoH support on Win7
@@ -719,6 +719,20 @@ HINTERNET PhpCreateHttpConnectionHandle(
);
}
+ {
+ ULONG option = WINHTTP_FLAG_SECURE_PROTOCOL_ALL |
+ WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 |
+ WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 |
+ WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3;
+
+ WinHttpSetOption(
+ httpSessionHandle,
+ WINHTTP_OPTION_SECURE_PROTOCOLS,
+ &option,
+ sizeof(ULONG)
+ );
+ }
+
WinHttpSetOption(
httpSessionHandle,
WINHTTP_OPTION_MAX_CONNS_PER_SERVER,
@@ -726,6 +740,20 @@ HINTERNET PhpCreateHttpConnectionHandle(
sizeof(ULONG)
);
+ if (WindowsVersion >= WINDOWS_10)
+ {
+ httpConnectionHandle = WinHttpConnect(
+ httpSessionHandle,
+ L"1.1.1.1",
+ INTERNET_DEFAULT_HTTPS_PORT,
+ 0
+ );
+ }
+ }
+
+ PhEndInitOnce(&initOnce);
+ }
+
// Cloudflare DoH
// https://developers.cloudflare.com/1.1.1.1/dns-over-https/wireformat/
// host: cloudflare-dns.com
@@ -743,6 +771,8 @@ HINTERNET PhpCreateHttpConnectionHandle(
// 2001:4860:4860::8888
// 2001:4860:4860::8844
+ if (WindowsVersion < WINDOWS_10)
+ {
httpConnectionHandle = WinHttpConnect(
httpSessionHandle,
L"1.1.1.1",
@@ -751,9 +781,6 @@ HINTERNET PhpCreateHttpConnectionHandle(
);
}
- PhEndInitOnce(&initOnce);
- }
-
return httpConnectionHandle;
}
@@ -855,7 +882,7 @@ static BOOLEAN PhpParseDnsMessageBuffer(
return FALSE;
}
-// DNS over HTTPs (DOH)
+// DNS over HTTPs (DoH)
// https://developers.cloudflare.com/1.1.1.1/dns-over-https/wireformat/
PDNS_RECORD PhHttpDnsQuery(
_In_ PWSTR DnsQueryMessage,
@@ -909,6 +936,22 @@ PDNS_RECORD PhHttpDnsQuery(
goto CleanupExit;
}
+ if (WindowsVersion <= WINDOWS_8)
+ {
+ ULONG option = SECURITY_FLAG_IGNORE_UNKNOWN_CA |
+ SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE |
+ SECURITY_FLAG_IGNORE_CERT_CN_INVALID |
+ SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
+
+ // Winhttp on Windows 7 doesn't support newer certificates. (dmex)
+ WinHttpSetOption(
+ httpRequestHandle,
+ WINHTTP_OPTION_SECURITY_FLAGS,
+ &option,
+ sizeof(ULONG)
+ );
+ }
+
if (!WinHttpSendRequest(
httpRequestHandle,
WINHTTP_NO_ADDITIONAL_HEADERS,
