Search code examples
vbscriptsha2winhttprequest

Server returned error - The data necessary to complete this operation is not yet available for VB script


Why can't the code below connect successfully to servers that require SHA2 certs? One of our partners had a SHA2 upgrade and they require us to have SHA2 certs. When we connect to their site that doesn't require SHA2 certs(only SHA1) it connects successfully with the code below. When we try to connect to a site that requires SHA2 certs(secure.anywhere.org) we get the error: Server returned error - The data necessary to complete this operation is not yet available . All of the correct SHA2 certs are installed. We have the Root and Intermediate certs installed for SHA2. Could this be an issue with WinHTTP? Or is this possibly something with our environment configuration that we need to fix?

Full error:

Server returned error: -2147483638 The data necessary to complete this operation is not yet available.

Code used to connect:

<%

On Error Resume Next
Response.ContentType = "text/html"
Dim xobj
Dim sPostData



Set xobj = CreateObject("WinHttp.WinHttpRequest.5.1")

If Err.Number <> 0 Then
Response.Write "<b>"
Response.Write "Error Creating XMLHTTP: " & Err.Number & "<BR>" &     Err.Description
Response.Write "</b>"
Response.End
End If 

If Not IsObject(xobj) Then
Response.Write "<b>"
Response.Write "xobj is not an object: " & Err.Number & "<BR>" & Err.Description
Response.Write "</b>"
Response.End
End If

qu = Request.form("SSN")


sPostData
sPostData = "user_id=abcd1234&password=67judlaufosaf&qu=" & qu

xobj.Open "POST", "https://www.anywhere.org/secure_area/test_panel.asp", False   
xobj.setRequestHeader "Referer", "https://www2.homeu.nc.edu/tns/connect.asp"
xobj.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xobj.Send sPostData

response.buffer = True
response.clear
response.ContentType = xobj.getResponseHeader("Content-Type")
response.AddHeader "Content-Type", xobj.getResponseHeader("Content-Type")

response.BinaryWrite xobj.responseBody

If Err.Number <> 0 Then
Response.Write "<b>"
    Response.Write "Server returned error: " & Err.Number & "<BR>" &  Err.Description
Response.Write "</b>"
Set xobj = nothing
Response.End
End If 

Set xobj = nothing
response.end
%>

Solution

  • This issue was due to Windows not having enough information to verify the SHA-2 cert. When we checked the status of the certs it had a status of "The issuer of this certificate could not be found". Here is a link to the solution.