I'm using a WinHttpRequest.5.1 object to make some https requests on an excel 365 (16.0.11328.20562) vba script.
I know that the certificate from server will occurs an error because the CN is wrong. Therefore I suppress this error with the option to ignore ssl errors.
I swear the following code worked two weeks ago and now it throws this error:
runtime error -2147012727 (80072f89) certificate invalid
Here is the code (included: Microsoft WinHTTP Services, version 5.1 [winhttpcom.dll]):
Sub test()
Dim url As String
url = "https://someserver:5096/api/v1/$metadata"
Dim winHttpReq As WinHttpRequest
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
'Ignoriere SSL-Errors
winHttpReq.Option(4) = 13056
'I also tested
'winHttpReq.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_Ignore_All
'winHttpReq.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_CertCNInvalid
winHttpReq.Open "GET", url, False
winHttpReq.Send ("")
Debug.Print winHttpReq.ResponseText
End Sub
I don't understand why I get an certificate invalid error, although ssl-errors should be ignored.
I hope you know why this happens and thank you in advance for your answers.