为ServerXMLHTTP.SetOption标识正确的客户端证书 [英] Identifying correct client certificate for ServerXMLHTTP.SetOption
问题描述
我在Windows 7中安装了三个客户端证书,需要使用特定的证书来使用VBA对ServerXMLHTTP60进行身份验证。
I have three client certificates installed in Windows 7 and need to use a specific one to authenticate a ServerXMLHTTP60 call using VBA.
使用友好名称调用ServerXMLHTTP60.SetOption证书的返回没有错误。但是随后的.send失败,并显示需要证书才能完成客户端身份验证。
Calling ServerXMLHTTP60.SetOption with the friendly name of the certificate returns with no error. But the subsequent .send fails with "A certificate is required to complete client authentication".
代码示例:
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在此站点上正常工作。我必须为证书使用错误的路径名。有没有办法确定正确的客户端证书路径名以确保成功?
The specified certificate is working fine via IE or Firefox with this site. I must be using an incorrect pathname for the certificate. Is there a way to determine the correct client certificate pathname to ensure success?
推荐答案
这让我发疯了几天,但是...
假设您将客户端安装到当前用户下的默认存储中,并且您的证书的主题为cn = mycert,那么这似乎可行。运行office16,Windows 10,winhttp5.1
This drove me mad for a couple of days but... Assuming you install your client to default store under current user and your certificate has subject cn=mycert then this seems to work. Running 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
这篇关于为ServerXMLHTTP.SetOption标识正确的客户端证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!