VBA ServerXMLHTTP https request with self signed certificate

后端 未结 2 925
小鲜肉
小鲜肉 2020-11-30 06:06

I\'m using a ServerXMLHTTP object to make some http requests on an excel 2007 vba script.

But I need to connect to an https server which uses a self-signed SSL Certi

2条回答
  •  鱼传尺愫
    2020-11-30 06:17

    I used to have this problem for a while, and I only managed to get past it thanks to this:

    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    objHTTP.SetOption 2, objHTTP.GetOption(2)
    objHTTP.Open "POST", "https://invernalia.homelinux.net", False, "user", "password"
    objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    objHTTP.send ("")
    

    I have found this here setOption Method and getOption Method

    Here in this code I have just used SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS but you can try with others more specific:

    • SXH_SERVER_CERT_IGNORE_WRONG_USAGE
    • SXH_SERVER_CERT_IGNORE_CERT_CN_INVALID
    • SXH_SERVER_CERT_IGNORE_CERT_DATE_INVALID
    • SXH_SERVER_CERT_IGNORE_UNKNOWN_CA

提交回复
热议问题