3

我在 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 与此站点正常工作。我必须为证书使用不正确的路径名。有没有办法确定正确的客户端证书路径名以确保成功?

4

1 回答 1

-1

这让我发疯了几天但是......假设您将客户端安装到当前用户下的默认存储并且您的证书具有主题 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
于 2018-06-19T08:23:31.740 回答