Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Using "setClientCertificate" when there are multiple certificates installed

$
0
0

I wrote a WinHttp POST request in VBA. It works good as long as there is only one certificate installed on the computer. However, some users have multiple certs with similar certificate names and therefore it returns an error:

a certificate is required to complete client authentication

Any suggestions on how I can select the correct certificate when multiple certificates share similar names? I've tried using both the "friendly name" and the "CN" name of the cert.

Below is my code:

Sub dapull()

Dim URL As String: URL = "https://ce.midwest.org/dart/xml/query"
Dim mfile As String

pulldate = Format(Worksheets("Sheet2").Range("date").Value, "yyyy-mm-dd")
mfile = "<?xml version="& """"& "1.0"& """"& "?><Envelope xmlns="& """"& "http://schemas.xmlsoap.org/soap/envelope/"& """"& "><Header/><Body><QueryRequest xmlns="& """"& "http://markets.midwest.org/dart/xml"& """"& "><QueryResults day="& """"& pulldate & """"& "><Location>BART</Location></QueryResults></QueryRequest></Body></Envelope>"
Set Req = New WinHttp.WinHttpRequest

With Req
    .Open "POST", URL, False
    .SetClientCertificate "CURRENT_USER\MY\name"'*this is the issue line
    .SetRequestHeader "content-type", "text/xml"
    .Send (mfile)
    .ResponseText
End With

End Sub

Viewing all articles
Browse latest Browse all 88835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>