From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
v2: PCERT_CHAIN_CONTEXT -> PCCERT_CHAIN_CONTEXT. Set last error before testing it. Improve patch subject.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/wininet/http.c | 13 +++++++++++++ dlls/wininet/tests/http.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index c9c4a060aac..1ca97cf3eb0 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2321,6 +2321,19 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe
*(ULONG*)buffer = hdr->ErrorMask; *size = sizeof(ULONG); + return ERROR_SUCCESS; + case INTERNET_OPTION_SERVER_CERT_CHAIN_CONTEXT: + TRACE("INTERNET_OPTION_SERVER_CERT_CHAIN_CONTEXT\n"); + + if (*size < sizeof(PCCERT_CHAIN_CONTEXT)) + return ERROR_INSUFFICIENT_BUFFER; + + if (!req->server->cert_chain) + return ERROR_INTERNET_INCORRECT_HANDLE_STATE; + + *(PCCERT_CHAIN_CONTEXT *)buffer = CertDuplicateCertificateChain(req->server->cert_chain); + *size = sizeof(PCCERT_CHAIN_CONTEXT); + return ERROR_SUCCESS; }
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index d1d7e678853..3b8f16a9fb2 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -6855,6 +6855,7 @@ static void test_secure_connection(void) INTERNET_CERTIFICATE_INFOW *certificate_structW = NULL; char certstr1[512], certstr2[512]; BOOL ret; + PCCERT_CHAIN_CONTEXT chain;
ses = InternetOpenA("Gizmo5", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); ok(ses != NULL, "InternetOpen failed\n"); @@ -6886,6 +6887,13 @@ static void test_secure_connection(void)
test_cert_struct(req, &test_winehq_org_cert);
+ size = sizeof(chain); + SetLastError(0xdeadbeef); + ret = InternetQueryOptionA(req, INTERNET_OPTION_SERVER_CERT_CHAIN_CONTEXT, &chain, &size); + ok(ret || GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE /* < IE8 */, + "InternetQueryOption failed: %u\n", GetLastError()); + if (ret) CertFreeCertificateChain(chain); + /* Querying the same option through InternetQueryOptionW still results in * ANSI strings being returned. */ @@ -7825,6 +7833,7 @@ static void test_cert_string(void) char actual[512]; DWORD size; BOOL res; + PCCERT_CHAIN_CONTEXT chain;
ses = InternetOpenA( "winetest", 0, NULL, NULL, 0 ); ok( ses != NULL, "InternetOpenA failed\n" ); @@ -7845,6 +7854,12 @@ static void test_cert_string(void) ok( size == 0, "unexpected size: %u\n", size ); ok( actual[0] == 0x55, "unexpected byte: %02x\n", actual[0] );
+ size = sizeof(chain); + SetLastError(0xdeadbeef); + res = InternetQueryOptionA(req, INTERNET_OPTION_SERVER_CERT_CHAIN_CONTEXT, &chain, &size); + ok(!res && (GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_STATE), + "InternetQueryOption failed: %u\n", GetLastError()); + InternetCloseHandle( req ); InternetCloseHandle( con ); InternetCloseHandle( ses );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=99841
Your paranoid android.
=== w8adm (32 bit report) ===
wininet: http.c:697: Test failed: req_error = 12007 http.c:708: Test failed: expected status 11 (INTERNET_STATUS_NAME_RESOLVED) 1 times, received 0 times http.c:721: Test failed: expected status 30 (INTERNET_STATUS_SENDING_REQUEST) 1 times, received 0 times http.c:722: Test failed: expected status 31 (INTERNET_STATUS_REQUEST_SENT) 1 times, received 0 times http.c:723: Test failed: expected status 40 (INTERNET_STATUS_RECEIVING_RESPONSE) 1 times, received 0 times http.c:724: Test failed: expected status 41 (INTERNET_STATUS_RESPONSE_RECEIVED) 1 times, received 0 times http.c:733: Test failed: flags = 8, expected 0 http.c:747: Test failed: Expected any header character, got 0x00 http.c:774: Test failed: Expected 0x0000, got 7777 http.c:937: Test failed: Returned zero size in response to request complete http.c:376: Test failed: unexpected status 10 (INTERNET_STATUS_RESOLVING_NAME) http.c:697: Test failed: req_error = 12007 http.c:718: Test failed: expected status 10 (INTERNET_STATUS_RESOLVING_NAME) 0 times, received 1 times http.c:721: Test failed: expected status 30 (INTERNET_STATUS_SENDING_REQUEST) 2 times, received 0 times http.c:722: Test failed: expected status 31 (INTERNET_STATUS_REQUEST_SENT) 2 times, received 0 times http.c:723: Test failed: expected status 40 (INTERNET_STATUS_RECEIVING_RESPONSE) 2 times, received 0 times http.c:724: Test failed: expected status 41 (INTERNET_STATUS_RESPONSE_RECEIVED) 2 times, received 0 times http.c:726: Test failed: expected status 110 (INTERNET_STATUS_REDIRECT) 1 times, received 0 times http.c:733: Test failed: flags = 8, expected 0 http.c:747: Test failed: Expected any header character, got 0x00 http.c:774: Test failed: Expected 0x0000, got 7777 http.c:797: Test failed: size = 37 http.c:797: Test failed: unexpected URL http://test.winehq.org/tests/redirect, expected http://test.winehq.org/tests/hello.html http.c:937: Test failed: Returned zero size in response to request complete http.c:376: Test failed: unexpected status 10 (INTERNET_STATUS_RESOLVING_NAME) http.c:376: Test failed: unexpected status 11 (INTERNET_STATUS_NAME_RESOLVED) http.c:718: Test failed: expected status 10 (INTERNET_STATUS_RESOLVING_NAME) 0 times, received 1 times http.c:719: Test failed: expected status 11 (INTERNET_STATUS_NAME_RESOLVED) 0 times, received 1 times
On Mon, 11 Oct 2021, Hans Leidekker wrote: [...]
- size = sizeof(chain);
- SetLastError(0xdeadbeef);
- ret = InternetQueryOptionA(req, INTERNET_OPTION_SERVER_CERT_CHAIN_CONTEXT, &chain, &size);
- ok(ret || GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE /* < IE8 */,
"InternetQueryOption failed: %u\n", GetLastError());
On Windows running urlmon:url before causes this ok() call (and others) to fail. Specifically it's now a set of 7 tests that urlmon:url breaks, but only in the first wininet:http run that follows:
C:\Users\Public\Documents>urlmon_test.exe url | findstr /R "tests.executed" 0d9c:url: 11156 tests executed (0 marked as todo, 0 failures), 0 skipped.
C:\Users\Public\Documents>wininet_test.exe http | findstr /R "tests.executed Test.failed" http.c:6886: Test failed: expected secure flag to be set http.c:6893: Test failed: InternetQueryOption failed: 12019 http.c:6903: Test failed: InternetQueryOption failed: 12016 http.c:6909: Test failed: InternetQueryOption failed: 12016 http.c:6932: Test failed: InternetQueryOption failed: 12016 http.c:6937: Test failed: InternetQueryOption failed: 12016 http.c:6940: Test failed: expected same string 13c0:http: 4871 tests executed (0 marked as todo, 7 failures), 1 skipped.
C:\Users\Public\Documents>wininet_test.exe http | findstr /R "tests.executed Test.failed" 0c04:http: 4884 tests executed (0 marked as todo, 0 failures), 0 skipped.
So where urlmon:url breaks some Windows setting, wininet:http seems to fix it, but only after the failures happened. I'm hoping that because you've worked on this test you'll have a good idea of what's going wrong and know how to fix it.
I'm tracking this issue in this bug: https://bugs.winehq.org//show_bug.cgi?id=51227
Also the patterns make the new failure quite visible (yay!): https://test.winehq.org/data/patterns.html#wininet:http