wininet: Use CertNameToStr for INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT

and update comment.
This commit is contained in:
Juan Lang 2006-02-16 12:19:00 +01:00 committed by Alexandre Julliard
parent e9c44cc0c4
commit 89529f8a8e

View file

@ -2259,15 +2259,56 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d
if (context)
{
LPINTERNET_CERTIFICATE_INFOW info = (LPINTERNET_CERTIFICATE_INFOW)lpBuffer;
DWORD strLen;
memset(info,0,sizeof(INTERNET_CERTIFICATE_INFOW));
info->ftExpiry = context->pCertInfo->NotAfter;
info->ftStart = context->pCertInfo->NotBefore;
if (bIsUnicode)
{
strLen = CertNameToStrW(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR,
NULL, 0);
info->lpszSubjectInfo = LocalAlloc(0,
strLen * sizeof(WCHAR));
if (info->lpszSubjectInfo)
CertNameToStrW(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR,
info->lpszSubjectInfo, strLen);
strLen = CertNameToStrW(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR,
NULL, 0);
info->lpszIssuerInfo = LocalAlloc(0,
strLen * sizeof(WCHAR));
if (info->lpszIssuerInfo)
CertNameToStrW(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR,
info->lpszIssuerInfo, strLen);
}
else
{
LPINTERNET_CERTIFICATE_INFOA infoA =
(LPINTERNET_CERTIFICATE_INFOA)info;
strLen = CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR,
NULL, 0);
infoA->lpszSubjectInfo = LocalAlloc(0, strLen);
if (infoA->lpszSubjectInfo)
CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR,
infoA->lpszSubjectInfo, strLen);
strLen = CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR,
NULL, 0);
infoA->lpszIssuerInfo = LocalAlloc(0, strLen);
if (infoA->lpszIssuerInfo)
CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR,
infoA->lpszIssuerInfo, strLen);
}
/*
* CertNameToStr implement requred for
* lpszSubjectInfo
* lpszIssuerInfo
*
* also need to set:
* Contrary to MSDN, these do not appear to be set.
* lpszProtocolName
* lpszSignatureAlgName
* lpszEncryptionAlgName