Question

I'm trying to build a webpage in classic ASP to check the status of a series of URLs.

My code is as follows:

Function TestSite(sURL)

  UserAgent = "Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1)"

  Set poster = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
  poster.open "GET", sURL, false
  poster.setRequestHeader "User-Agent",UserAgent
  poster.send

  If poster.status = 200 Then
    TestSite = poster.responseText
  Else
    ' ## ERROR ## '
    TestSite = ""
  End If
  Set poster = Nothing
End Function

The URLs are all HTTPS with non-standard port numbers included (eg https://somedomain.com:4433/restofurl)

When I run the urls in a web browser, they load just fine, but when I put them through the above function I get:

A connection with the server could not be established

I've checked my function with the following alternatives: 1) A non secure URL - this works fine 2) A secure URL with no port specified - this works fine 3) A secure URL specifying port 443 - this works fine 4) A secure URL specifying port 443 on the target server - THIS works fine

On the basis of that, I'm as sure as I can be that my code is correct. Does anyone have any suggestions for further troubleshooting?

Was it helpful?

Solution

The problem proved to be related to our server being old (still running Win2003) and their setup being even more non-standard than the port numbers suggest!

The final solution was to host the code on some separate hosting (on a server running a more recent version of Windows). Not ideal, but at least we've got it working. (There is a server upgrade in our future, too - which will hopefully be the final solution.)

OTHER TIPS

This probably means that the server that runs your code does not have the same certificates as the server you are sending the request to. While the browser you are using does have them.

You can check this by making your server ignore particular certificate problems by adding this code (before you send the request, off course), and trying out some of the values:

Const SXH_SERVER_CERT_IGNORE_UNKNOWN_CA = 256
Const SXH_SERVER_CERT_IGNORE_WRONG_USAGE = 512
Const SXH_SERVER_CERT_IGNORE_CERT_CN_INVALID = 4096
Const SXH_SERVER_CERT_IGNORE_CERT_DATE_INVALID = 8192
Const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056
poster.setOption 2, poster.getOption(2) - SXH_SERVER_CERT_IGNORE_CERT_DATE_INVALID
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top