1. 文件包含:
#include <certenroll.h>
2. 接口定义:
interface IX509ExtensionAuthorityKeyIdentifier : public IX509Extension
{
public:
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RawData(
/* [retval][out] */ VARIANT *pRawData) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_IssuerName(
/* [retval][out] */ IX500DistinguishedName **ppValue) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_IssuerName(
/* [in] */ IX500DistinguishedName *pValue) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SerialNumber(
/* [retval][out] */ BSTR *pValue) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SerialNumber(
/* [in] */ BSTR Value) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_KeyIdentifier(
/* [retval][out] */ VARIANT *pValue) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_KeyIdentifier(
/* [in] */ VARIANT Value) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE InitializeEncode(
/* [in] */ VARIANT IssuerName,
/* [in] */ VARIANT SerialNumber,
/* [in] */ VARIANT KeyIdentifier) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE InitializeDecode(
/* [in] */ BSTR strEncodedData) = 0;
};
3. 使用示例:
// 创建对象
CComPtr<IX509ExtensionAuthorityKeyIdentifier> pAuthorityKeyIdentifier;
HRESULT hr = CoCreateInstance(
__uuidof(CX509ExtensionAuthorityKeyIdentifier),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IX509ExtensionAuthorityKeyIdentifier),
(void**)&pAuthorityKeyIdentifier);
if (SUCCEEDED(hr))
{
// 获取原始数据
VARIANT rawData;
hr = pAuthorityKeyIdentifier->get_RawData(&rawData);
// 获取颁发者名称
CComPtr<IX500DistinguishedName> pIssuerName;
hr = pAuthorityKeyIdentifier->get_IssuerName(&pIssuerName);
// 设置颁发者名称
hr = pAuthorityKeyIdentifier->put_IssuerName(pIssuerName);
// 获取序列号
BSTR serialNumber;
hr = pAuthorityKeyIdentifier->get_SerialNumber(&serialNumber);
// 设置序列号
hr = pAuthorityKeyIdentifier->put_SerialNumber(serialNumber);
// 获取密钥标识符
VARIANT keyIdentifier;
hr = pAuthorityKeyIdentifier->get_KeyIdentifier(&keyIdentifier);
// 设置密钥标识符
hr = pAuthorityKeyIdentifier->put_KeyIdentifier(keyIdentifier);
// 在这里可以使用获取到的对象进行操作
// 释放资源
VariantClear(&rawData);
SysFreeString(serialNumber);
}
请注意,上述代码中的 CX509ExtensionAuthorityKeyIdentifier 类是 IX509ExtensionAuthorityKeyIdentifier 接口的默认实现之一。在实际使用时,你可能需要根据你的需求设置颁发者名称、序列号和密钥标识符。确保在使用这些接口时参考相关的官方文档和示例代码。
转载请注明出处:http://www.zyzy.cn/article/detail/24227/Win32 API/Certenroll.h/IX509ExtensionAuthorityKeyIdentifier