Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to POST HTTPS request using VBScript

Tags:

https

vbscript

I want to know how to make a HTTPS request from a VBScript client.

After receiving the request, how to decrypt the HTTPS response?

like image 954
Dungeon Hunter Avatar asked May 06 '11 05:05

Dungeon Hunter


2 Answers

HTTPS is not just an encryption format - it's a transport security protocol, with complex negotiation built-in. Just like you wouldn't try to build an HTTP client component in VBScript, similarly you wouldn't try to build an HTTPS/SSL client.

The VBScript language doesn't include any HTTP or HTTPS client, but windows has a couple of COM objects that can be used (from Windows Script Host of from ASP pages written in VBScript), and VBScript code running in internet explorer can similarly access a browser object that allows HTTPS calls.

From windows (WSH/ASP), the best object is typically MSXML2.ServerXmlHTTP, for example see this quick overview: http://www.developerfusion.com/article/3272/posting-form-data-to-a-web-page/2/

From Internet Explorer, as long as you're not dealing with legacy versions, the best idea is to use the cross-browser standard object XMLHttpRequest. The following page gives you an overview: http://www.jibbering.com/2002/4/httprequest.html

All of these HTTP clients also support HTTPS.

like image 165
Tao Avatar answered Nov 14 '22 21:11

Tao


dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP")

xHttp.Open "GET", "https://yourhost.example.com/foo", False

' 2 stands for SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS
' 13056 means ignore all server side cert error
xHttp.setOption 2, 13056
xHttp.Send

' read response body
WScript.Echo xHttp.responseBody

Reference:

  • getOption Method of XML DOM
  • setOption Method of XML DOM
like image 6
shawnzhu Avatar answered Nov 14 '22 21:11

shawnzhu