vba - 为 ServerXMLHTTP.SetOption 识别正确的客户端证书

标签 vba client-certificates serverxmlhttp internetsetoption

我在 Windows 7 中安装了三个客户端证书,需要使用一个特定的证书来验证使用 VBA 的 ServerXMLHTTP60 调用。

使用证书的友好名称调用 ServerXMLHTTP60.SetOption 将无错误返回。但是随后的 .send 失败并显示“需要证书才能完成客户端身份验证”。

代码示例:

    Public Sub TestCert()
    Dim myHTTP as New ServerXMLHTTP60
    Dim myURL as String

        ' Open the connection to the secure server
         myHTTP.Open "GET", "https://server/finalpath", False

        ' Attempt to set the correct client certificate
        ' I have also tried just the friendly name as well as 
        ' LOCAL_MACHINE\My\cert friendly name'
        myHTTP.SetOption 3, "CURRENT_USER\My\cert friendly name"

        ' Send request fails with "A certificate is required ..."
        myHTTP.Send
    End Sub

指定的证书通过 IE 或 Firefox 与此站点正常工作。我一定是为证书使用了不正确的路径名。有没有办法确定正确的客户端证书路径名以确保成功?

最佳答案

这让我发疯了几天,但是...... 假设您将客户端安装到当前用户下的默认存储并且您的证书主题为 cn=mycert 那么这似乎可行。运行office16、windows 10、winhttp5.1

Dim apiConnection As New WinHttp.WinHttpRequest

' Set the authentication settings
apiConnection.SetClientCertificate "mycert"

apiConnection.Open "Get", "https://localhost:8443", False
apiConnection.Send

关于vba - 为 ServerXMLHTTP.SetOption 识别正确的客户端证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31942165/

相关文章:

C# request.GetClientCertificate() 在处理具有较大负载的 PUT/POST 请求时卡住

dart - Flutter/Dart语言客户端证书认证

asp-classic - 在经典asp中将utf-8转换为iso-8859-1

vba - Excel:使用两个不同的范围创建下拉列表

excel - 如何使用VBA从Excel工作表中的图片获取EXIF信息

c - 如何使用 mbedTLS 库或 openssl 检查证书是 CA 还是用户证书

asp-classic - 尝试将 ASP 页面下载到文件时出现 401 未经授权的错误

vba - 将字符串变量传递给 Variant 参数时类型不匹配,并将 Array 函数的结果分配给参数

vba - 无法在 Excel 2007 VBA 中使用 Option Strict Off 进行后期绑定(bind)

asp-classic - ASP页面中的msxml3.dll错误 '80072ee2'