Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSXML2.ServerXMLHTTP clientcertificate

I'm using MSXML2.ServerXMLHTTP in JScript / VBA and want to set the client certificate path. In WinHTTP.WinHTTPRequest I could use the option '.setClientCertificate', but this seems absent in MSXML2.ServerXMLHTTP.

Is there any argument I can use for this to get the same effect? I need to use MSXML2.ServerXMLHTTP as I'm using it a-synchronously and WinHTTP doesn't support that.

Example code JScript/VBA:

var H = new ActiveXObject('MSXML2.ServerXMLHTTP.6.0')
    H.open('GET', 'https://stackoverflow.com/', true)
    H.setRequestHeader('Cookie', 'yesplease')
    H.setClientCertificate('CURRENT_USER\MY\USERNAME')  <-- this line doesn't work
    H.send

So the above errors on the setClientCertificate line. However, the below would work (but as mentioned I can't use WinHTTP)

var H = new ActiveXObject('WinHTTP.WinHTTPRequest.5.1')
    H.open('GET', 'https://stackoverflow.com/', true)
    H.setRequestHeader('Cookie', 'yesplease')
    H.setClientCertificate('CURRENT_USER\MY\USERNAME')  <-- this line DOES work
    H.send

Is there a way I can use the setClientCertificate with the MSXML2.ServerHTTP object?

like image 483
JasperD Avatar asked Oct 30 '25 03:10

JasperD


1 Answers

You want

.setOption 3, "\value\......."

It is detailed here:

https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ms763811(v%3Dvs.85) under `SXH_OPTION_SELECT_CLIENT_SSL_CERT`

Syntax

oServerXMLHTTPRequest.setOption option, value

As per your code

H.setOption 3, "CURRENT_USER\\MY\\USERNAME"

For the constant

SXH_OPTION_SELECT_CLIENT_SSL_CERT = 3 '&H3
like image 170
QHarr Avatar answered Nov 02 '25 23:11

QHarr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!