[PATCH v2 0/1] MR10390: winhttp: Support Qyuery option WINHTTP_OPTION_SECURITY_INFO
-- v2: winhttp: Support Query option WINHTTP_OPTION_SECURITY_INFO. https://gitlab.winehq.org/wine/wine/-/merge_requests/10390
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> --- dlls/winhttp/session.c | 19 +++++++++++++++++++ dlls/winhttp/tests/winhttp.c | 23 +++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c index 6348ec67b82..99c00af1634 100644 --- a/dlls/winhttp/session.c +++ b/dlls/winhttp/session.c @@ -23,6 +23,7 @@ #include "winsock2.h" #include "ws2ipdef.h" #include "ws2tcpip.h" +#include "schannel.h" #include "winhttp.h" #include "winreg.h" #include "winternl.h" @@ -821,6 +822,24 @@ static BOOL request_query_option( struct object_header *hdr, DWORD option, void *buflen = sizeof(flags); return TRUE; } + case WINHTTP_OPTION_SECURITY_INFO: + { + WINHTTP_SECURITY_INFO *info = (WINHTTP_SECURITY_INFO *)buffer; + SECURITY_STATUS res; + + if (!validate_buffer( buffer, buflen, sizeof(WINHTTP_SECURITY_INFO) )) return FALSE; + + memset(info, 0 , sizeof(WINHTTP_SECURITY_INFO)); + if (!request->netconn || !request->netconn->secure) return TRUE; + res = QueryContextAttributesW( &request->netconn->ssl_ctx, SECPKG_ATTR_CONNECTION_INFO, + (void*)&info->ConnectionInfo ); + if(res != SEC_E_OK) + WARN( "QueryContextAttributesW failed: %#lx\n", res ); + res = QueryContextAttributesW( &request->netconn->ssl_ctx, SECPKG_ATTR_CIPHER_INFO, (void*)&info->CipherInfo ); + if(res != SEC_E_OK) + WARN( "QueryContextAttributesW failed: %#lx\n", res ); + return TRUE; + } case WINHTTP_OPTION_SERVER_CERT_CONTEXT: { const CERT_CONTEXT *cert; diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index b4ad4a67803..863cd15ab5c 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -24,6 +24,7 @@ #include <windef.h> #include <winsock2.h> #include <ws2tcpip.h> +#include <schannel.h> #include <winhttp.h> #include <wincrypt.h> #include <winreg.h> @@ -69,6 +70,7 @@ static void test_WinHttpQueryOption(void) BOOL ret; HINTERNET session, request, connection; DWORD feature, size; + WINHTTP_SECURITY_INFO info; SetLastError(0xdeadbeef); session = WinHttpOpen(L"winetest", 0, 0, 0, 0); @@ -283,6 +285,17 @@ static void test_WinHttpQueryOption(void) ok(!ret, "should fail to query option\n"); ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError() ); + size = sizeof(info); + info.ConnectionInfo.dwProtocol = 0xdeadbeef; + info.ConnectionInfo.dwCipherStrength = 0xdeadbeef; + ret = WinHttpQueryOption(request, WINHTTP_OPTION_SECURITY_INFO, &info, &size); + ok(ret, "got %lu\n", GetLastError()); + if (ret) + { + ok(info.ConnectionInfo.dwProtocol == 0, "got %lu\n", info.ConnectionInfo.dwProtocol); + ok(info.ConnectionInfo.dwCipherStrength == 0, "got %lu\n", info.ConnectionInfo.dwCipherStrength); + } + SetLastError(0xdeadbeef); ret = WinHttpCloseHandle(request); ok(ret, "WinHttpCloseHandle failed on closing request: %lu\n", GetLastError()); @@ -1088,6 +1101,7 @@ static void test_secure_connection(void) BOOL ret; CERT_CONTEXT *cert; WINHTTP_CERTIFICATE_INFO info; + WINHTTP_SECURITY_INFO secinfo; char buffer[32]; ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0); @@ -1213,6 +1227,15 @@ static void test_secure_connection(void) LocalFree( info.lpszIssuerInfo ); } + size = sizeof(secinfo); + ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_INFO, &secinfo, &size); + ok(ret, "got %lu\n", GetLastError()); + if (ret) + { + ok(secinfo.ConnectionInfo.dwProtocol == SP_PROT_TLS1_2_CLIENT, "got %lu\n", secinfo.ConnectionInfo.dwProtocol); + ok(secinfo.ConnectionInfo.dwCipherStrength == info.dwKeySize, "got %lu\n", secinfo.ConnectionInfo.dwCipherStrength); + } + ret = WinHttpReceiveResponse(req, NULL); if (!ret && GetLastError() == ERROR_WINHTTP_CONNECTION_ERROR) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10390
This merge request was approved by Hans Leidekker. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10390
participants (3)
-
Alistair Leslie-Hughes -
Alistair Leslie-Hughes (@alesliehughes) -
Hans Leidekker (@hans)