我在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在此站点上正常运行。我必须使用不正确的路径名作为证书。有没有办法确定正确的客户端证书路径名以确保成功?
答案 0 :(得分:0)
这让我生气了几天但...... 假设您将客户端安装到当前用户下的默认存储区,并且您的证书主题为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