CertGetStoreProperty 함수(wincrypt.h)

CertGetStoreProperty 함수는 저장소 속성을 검색합니다.

구문

BOOL CertGetStoreProperty(
  [in]      HCERTSTORE hCertStore,
  [in]      DWORD      dwPropId,
  [out]     void       *pvData,
  [in, out] DWORD      *pcbData
);

매개 변수

[in] hCertStore

열려 있는 인증서 저장소의 핸들입니다.

[in] dwPropId

저장소 속성 범위 중 하나를 나타냅니다. 미리 정의된 저장소 속성 CERT_STORE_LOCALIZED_NAME_PROP_ID 저장소의 지역화된 이름이 하나 있습니다.

사용자 정의 속성은 미리 정의된 컨텍스트 속성의 현재 값 범위를 벗어나야 합니다. 현재 사용자 정의 dwPropId 값은 4,096부터 시작합니다.

[out] pvData

dwPropId에 의해 결정된 대로 데이터를 수신하는 버퍼에 대한 포인터입니다. CERT_STORE_LOCALIZED_NAME_PROP_ID 경우 이는 저장소의 지역화된 이름이며 pvData 는 null로 끝나는 유니코드 와이드 문자 문자열을 가리킵니다. 다른 dwPropId의 경우 pvData 는 바이트 배열을 가리킵니다.

이 매개 변수는 메모리 할당을 위해 이 정보의 크기를 설정하는 NULL 일 수 있습니다. 자세한 내용은 알 수 없는 길이의 데이터 검색을 참조하세요.

[in, out] pcbData

pvData 버퍼의 크기(바이트)를 지정하는 DWORD 값에 대한 포인터입니다. 함수가 반환되면 DWORD 값에는 버퍼에 저장된 바이트 수가 포함됩니다.

반환 값

함수가 성공하면 함수는 0이 아닌 값을 반환합니다.

함수가 실패하면 0을 반환합니다.

저장소 속성을 찾은 경우 함수는 0이 아닌 값을 반환하고 pvData 는 속성을 가리키고 pcbData 는 문자열 길이를 가리킵니다. store 속성을 찾을 수 없는 경우 함수는 0을 반환하고 GetLastError 는 CRYPT_E_NOT_FOUND 반환합니다.

설명

스토어 속성 식별자는 전체 저장소에 적용할 수 있는 속성입니다. 개별 인증서, CRL( 인증서 해지 목록 ) 또는 CTL( 인증서 신뢰 목록 ) 컨텍스트의 속성이 아닙니다. 현재 저장소 속성은 유지되지 않습니다.

지역화된 저장소 이름을 찾으려면 CryptFindLocalizedName 함수를 사용할 수도 있습니다.

예제

다음 예제에서는 로컬 이름 속성에 대해 저장소를 쿼리하는 방법을 보여줍니다. 유사한 코드를 사용하여 다른 저장소 속성을 검색할 수 있습니다. 이 함수를 사용하는 전체 예제는 예제 C 프로그램: 인증서 저장소 속성 설정 및 가져오기를 참조하세요.

#include <windows.h>
#include <stdio.h>
#include <Wincrypt.h>


//--------------------------------------------------------------------
// Declare and initialize variables.
void *pvData = NULL;
DWORD cbData = 0;

//--------------------------------------------------------------------
// Call CertGetStoreProperty a first time
// to get the length of the store name string to be returned.
// hCertStore is a previously assigned HCERTSTORE variable that
// represents an open certificate store.
if(CertGetStoreProperty(
    hCertStore,
    CERT_STORE_LOCALIZED_NAME_PROP_ID,
    NULL,     // NULL on the first call  
              // to establish the length of the string
              // to be returned
    &cbData))
{
     printf("The length of the property is %d. \n",cbData);
}
else
{
     printf("The length of the property was not calculated.\n");
     exit(1);
}

//--------------------------------------------------------------------
// cbData is the length of a string to be allocated. 
// Allocate the space for the string and call the function a 
// second time.
if(pvData = malloc(cbData))
{
     printf("%d bytes of memory allocated.\n",cbData);
}
else
{
     printf("Memory was not allocated.\n");
     exit(1);
}

// Call CertGetStoreProperty a second time
// to copy the local store name into the pvData buffer.
if(CertGetStoreProperty(
    hCertStore,
    CERT_STORE_LOCALIZED_NAME_PROP_ID,
    pvData,
    &cbData))
{
     printf("The localized name is %S.\n",pvData);
}
else
{
     printf("CertGetStoreProperty failed.\n");
     exit(1);
}

// Free memory when done.
if (pvData)
    free(pvData);

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows XP [데스크톱 앱 | UWP 앱]
지원되는 최소 서버 Windows Server 2003 [데스크톱 앱 | UWP 앱]
대상 플랫폼 Windows
헤더 wincrypt.h
라이브러리 Crypt32.lib
DLL Crypt32.dll

추가 정보

CertSetStoreProperty

인증서 저장소 함수