vbscript下载文件(绕过无效的证书错误) [英] vbscript to download a file (bypassing invalid certificate errors)

查看:162
本文介绍了vbscript下载文件(绕过无效的证书错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pre> dim xHttp:设置xHttp = createobject(microsoft.xmlhttp)
dim bStrm:设置bStrm = createobject(Adodb.Stream)
xHttp。打开GET,https://www.website.com/apps/CertMgr.Exe,False
xHttp.Send

with bStrm
.type = 1' // binary
.open
.write xHttp.responseBody
.savetofilec:\CertMgr.Exe,2'//覆盖
结束

使用上述代码我试图从安全的网站下载文件,以自动安装安全证书,它的工作正常从http站点,但我需要绕过安全错误。任何想法?

解决方案

您需要从MSXML2.XMLHTTP切换到 MSXML2.ServerXMLHTTP ,并使用 setOption 方法,值为 SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS 。只需在打开和发送之间拨打电话。以下是您使用新代码更新的示例。

  const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056 
dim xHttp:设置xHttp = createobject( MSXML2.ServerXMLHTTP)
dim bStrm:设置bStrm = createobject(Adodb.Stream)
xHttp.OpenGET,https://www.website.com/apps/CertMgr.Exe ,False
xHttp.setOption 2,SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
xHttp.Send

with bStrm
.type = 1'// binary
.open
.write xHttp.responseBody
.savetofilec:\CertMgr.Exe,2'//覆盖
结束


dim xHttp: Set xHttp = createobject("microsoft.xmlhttp")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", "https://www.website.com/apps/CertMgr.Exe", False
xHttp.Send

with bStrm
    .type = 1 '//binary
    .open
    .write xHttp.responseBody
    .savetofile "c:\CertMgr.Exe", 2 '//overwrite
end with

Using the above code I'm trying to download a file from a secure site to install a security certificate automatically, it works fine from a http site, but I'm needing to bypass the security errors. Any ideas?

解决方案

You need to switch from MSXML2.XMLHTTP to MSXML2.ServerXMLHTTP and use the setOption method with the value SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS. Just place the call between Open and Send. Here's your example updated with the new code.

const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056
dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", "https://www.website.com/apps/CertMgr.Exe", False
xHttp.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
xHttp.Send

with bStrm
    .type = 1 '//binary
    .open
    .write xHttp.responseBody
    .savetofile "c:\CertMgr.Exe", 2 '//overwrite
end with

这篇关于vbscript下载文件(绕过无效的证书错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆