winhttp: Add a partial implementation of WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT.
This commit is contained in:
parent
a610fc17d8
commit
be37038090
|
@ -559,6 +559,18 @@ static void str_to_buffer( WCHAR *buffer, const WCHAR *str, LPDWORD buflen )
|
|||
*buflen = len * sizeof(WCHAR);
|
||||
}
|
||||
|
||||
static WCHAR *blob_to_str( DWORD encoding, CERT_NAME_BLOB *blob )
|
||||
{
|
||||
WCHAR *ret;
|
||||
DWORD size, format = CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG;
|
||||
|
||||
size = CertNameToStrW( encoding, blob, format, NULL, 0 );
|
||||
if ((ret = LocalAlloc( 0, size * sizeof(WCHAR) )))
|
||||
CertNameToStrW( encoding, blob, format, ret, size );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen )
|
||||
{
|
||||
request_t *request = (request_t *)hdr;
|
||||
|
@ -598,6 +610,34 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
|
|||
*buflen = sizeof(cert);
|
||||
return TRUE;
|
||||
}
|
||||
case WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT:
|
||||
{
|
||||
const CERT_CONTEXT *cert;
|
||||
WINHTTP_CERTIFICATE_INFO *ci = buffer;
|
||||
|
||||
FIXME("partial stub\n");
|
||||
|
||||
if (!buffer || *buflen < sizeof(*ci))
|
||||
{
|
||||
*buflen = sizeof(*ci);
|
||||
set_last_error( ERROR_INSUFFICIENT_BUFFER );
|
||||
return FALSE;
|
||||
}
|
||||
if (!(cert = netconn_get_certificate( &request->netconn ))) return FALSE;
|
||||
|
||||
ci->ftExpiry = cert->pCertInfo->NotAfter;
|
||||
ci->ftStart = cert->pCertInfo->NotBefore;
|
||||
ci->lpszSubjectInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Subject );
|
||||
ci->lpszIssuerInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Issuer );
|
||||
ci->lpszProtocolName = NULL;
|
||||
ci->lpszSignatureAlgName = NULL;
|
||||
ci->lpszEncryptionAlgName = NULL;
|
||||
ci->dwKeySize = 128;
|
||||
|
||||
CertFreeCertificateContext( cert );
|
||||
*buflen = sizeof(*ci);
|
||||
return TRUE;
|
||||
}
|
||||
case WINHTTP_OPTION_SECURITY_KEY_BITNESS:
|
||||
{
|
||||
if (!buffer || *buflen < sizeof(DWORD))
|
||||
|
|
|
@ -770,6 +770,7 @@ static void test_secure_connection(void)
|
|||
DWORD size, status, policy, bitness;
|
||||
BOOL ret;
|
||||
CERT_CONTEXT *cert;
|
||||
WINHTTP_CERTIFICATE_INFO info;
|
||||
|
||||
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
||||
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
||||
|
@ -823,6 +824,17 @@ static void test_secure_connection(void)
|
|||
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_KEY_BITNESS, &bitness, &size );
|
||||
ok(ret, "failed to retrieve key bitness %u\n", GetLastError());
|
||||
|
||||
size = sizeof(info);
|
||||
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT, &info, &size );
|
||||
ok(ret, "failed to retrieve certificate info %u\n", GetLastError());
|
||||
|
||||
trace("lpszSubjectInfo %s\n", wine_dbgstr_w(info.lpszSubjectInfo));
|
||||
trace("lpszIssuerInfo %s\n", wine_dbgstr_w(info.lpszIssuerInfo));
|
||||
trace("lpszProtocolName %s\n", wine_dbgstr_w(info.lpszProtocolName));
|
||||
trace("lpszSignatureAlgName %s\n", wine_dbgstr_w(info.lpszSignatureAlgName));
|
||||
trace("lpszEncryptionAlgName %s\n", wine_dbgstr_w(info.lpszEncryptionAlgName));
|
||||
trace("dwKeySize %u\n", info.dwKeySize);
|
||||
|
||||
ret = WinHttpReceiveResponse(req, NULL);
|
||||
ok(ret, "failed to receive response %u\n", GetLastError());
|
||||
|
||||
|
|
Loading…
Reference in New Issue