简体   繁体   English

将SSL客户端证书与IXMLHTTPRequest3一起使用

[英]Using a SSL client certificate with IXMLHTTPRequest3

I am using IXMLHTTPRequest3 from C++ code to issue a request to a service. 我正在使用C ++代码中的IXMLHTTPRequest3向服务发出请求。 This request needs to be accompanied by a client certificate (which is just about the only thing that IXHR3 adds over IXHR2). 该请求需要随附一个客户机证书(这是IXHR3在IXHR2之上添加的唯一内容)。

The certificate's thumbprint is 8D1CC03002D7872230516B5C5BA1090084D68ED0, and I have verified that it is installed on the computer: 证书的指纹为8D1CC03002D7872230516B5C5BA1090084D68ED0,并且我已验证该证书已安装在计算机上:

PS> dir cert:\*\*\* | ? { $_.Thumbprint -eq "8D1CC03002D7872230516B5C5BA1090084D68ED0" }

    Directory: Microsoft.PowerShell.Security\Certificate::LocalMachine\My

Thumbprint                                Subject
----------                                -------
8D1CC03002D7872230516B5C5BA1090084D68ED0  DC=..., O=..., OU=...

However, when I try to pass that thumbprint to IXHR3->SetClientCertificate , I get back 0x80092004, CRYPT_E_NOT_FOUND . 但是,当我尝试将指纹传递给IXHR3->SetClientCertificate ,我得到0x80092004 CRYPT_E_NOT_FOUND

I converted the hash from a hex string to a 20-byte array (through automation to avoid transposition mistakes on my end) and my invocation looks like this: 我将哈希值从十六进制字符串转换为20字节数组(通过自动操作以避免在我端发生转置错误),我的调用如下所示:

uint8_t thumbprint[20] = { 0x8d, 0x1c, 0xc0, 0x30, ... };
hr = request->SetClientCertificate(ARRAYSIZE(thumbprint), thumbprint, nullptr);

The question, clearly, is: why can't IXHR3 find my client certificate? 问题显然是:IXHR3为什么找不到我的客户证书?

IXHR3仅在CERT_STORE_PROV_SYSTEM > CERT_SYSTEM_STORE_CURRENT_USER查找证书,而我的则在CERT_SYSTEM_STORE_LOCAL_MACHINE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM