wininet: Returned certificate strings are always ASCII.

This commit is contained in:
Juan Lang 2010-09-30 13:09:04 -07:00 committed by Alexandre Julliard
parent 86732e04d8
commit 56ebc04ab6
2 changed files with 17 additions and 48 deletions

View File

@ -1820,60 +1820,33 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe
case INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT: {
PCCERT_CONTEXT context;
if(*size < sizeof(INTERNET_CERTIFICATE_INFOW)) {
*size = sizeof(INTERNET_CERTIFICATE_INFOW);
if(*size < sizeof(INTERNET_CERTIFICATE_INFOA)) {
*size = sizeof(INTERNET_CERTIFICATE_INFOA);
return ERROR_INSUFFICIENT_BUFFER;
}
context = (PCCERT_CONTEXT)NETCON_GetCert(&(req->netConnection));
if(context) {
INTERNET_CERTIFICATE_INFOW *info = (INTERNET_CERTIFICATE_INFOW*)buffer;
INTERNET_CERTIFICATE_INFOA *info = (INTERNET_CERTIFICATE_INFOA*)buffer;
DWORD len;
memset(info, 0, sizeof(INTERNET_CERTIFICATE_INFOW));
info->ftExpiry = context->pCertInfo->NotAfter;
info->ftStart = context->pCertInfo->NotBefore;
if(unicode) {
len = CertNameToStrW(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR, NULL, 0);
info->lpszSubjectInfo = LocalAlloc(0, len*sizeof(WCHAR));
if(info->lpszSubjectInfo)
CertNameToStrW(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR,
info->lpszSubjectInfo, len);
len = CertNameToStrW(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR, NULL, 0);
info->lpszIssuerInfo = LocalAlloc(0, len*sizeof(WCHAR));
if (info->lpszIssuerInfo)
CertNameToStrW(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR,
info->lpszIssuerInfo, len);
}else {
INTERNET_CERTIFICATE_INFOA *infoA = (INTERNET_CERTIFICATE_INFOA*)info;
len = CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR, NULL, 0);
infoA->lpszSubjectInfo = LocalAlloc(0, len);
if(infoA->lpszSubjectInfo)
CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR,
infoA->lpszSubjectInfo, len);
len = CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR, NULL, 0);
infoA->lpszIssuerInfo = LocalAlloc(0, len);
if(infoA->lpszIssuerInfo)
CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR,
infoA->lpszIssuerInfo, len);
}
/*
* Contrary to MSDN, these do not appear to be set.
* lpszProtocolName
* lpszSignatureAlgName
* lpszEncryptionAlgName
* dwKeySize
*/
len = CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR, NULL, 0);
info->lpszSubjectInfo = LocalAlloc(0, len);
if(info->lpszSubjectInfo)
CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Subject, CERT_SIMPLE_NAME_STR,
info->lpszSubjectInfo, len);
len = CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR, NULL, 0);
info->lpszIssuerInfo = LocalAlloc(0, len);
if(info->lpszIssuerInfo)
CertNameToStrA(context->dwCertEncodingType,
&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR,
info->lpszIssuerInfo, len);
CertFreeCertificateContext(context);
return ERROR_SUCCESS;
}

View File

@ -2693,11 +2693,9 @@ static void test_secure_connection(void)
ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
if (ret)
{
todo_wine
ok(certificate_structA->lpszSubjectInfo &&
strlen(certificate_structA->lpszSubjectInfo) > 1,
"expected a non-empty subject name\n");
todo_wine
ok(certificate_structA->lpszIssuerInfo &&
strlen(certificate_structA->lpszIssuerInfo) > 1,
"expected a non-empty issuer name\n");
@ -2726,11 +2724,9 @@ static void test_secure_connection(void)
ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
if (ret)
{
todo_wine
ok(certificate_structA->lpszSubjectInfo &&
strlen(certificate_structA->lpszSubjectInfo) > 1,
"expected a non-empty subject name\n");
todo_wine
ok(certificate_structA->lpszIssuerInfo &&
strlen(certificate_structA->lpszIssuerInfo) > 1,
"expected a non-empty issuer name\n");