Determining if a Server Supports SSL

  • Thread starter Thread starter Christopher D. Wiederspan
  • Start date Start date
C

Christopher D. Wiederspan

I've got a simple problem. Currently, I have a .Config setting called
SupportsSSL that I use within an ASP.NET web application to determine
whether I redirect to an HTTP or HTTPS connection (for instance, when the
user visits the Login page). I'm wondering if there is a programatic way to
determine this instead of keeping track of different Machine.Config settings
on different machines...?

What I'm really striving for is that for our Production web servers, we've
got the SSL certificates setup, and on our development servcers, we don't.
Therefore I need to redirect slightly differently on the two different farms
in order to avoid "Cannot Find Server" errors when trying to hit an HTTPS
url on an development machine.

Any ideas would be appreciated.

Thanks,
Chris
 
Why don't you just install certificates on your development box like
everybody else? Any certificate will do (even your production one), you'll
just have to live with the browser complaining unless you want to pay for a
trusted certificate or create and install your own CA certificate.

Jerry
 
Hi Chris,

Based on my research and experience, we can first try to make an HTTPS
connect to the web server before taking any further action. If the web
server doesn't support SSL, an error should be returned. Here is the sample
code (VB.NET):

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
' Initialize the WebRequest.
Dim myRequest As WebRequest =
WebRequest.Create("https://www.microsoft.com")

Try
' Return the response.
Dim myResponse As WebResponse = myRequest.GetResponse()

' Code to use the WebResponse goes here.
' Close the response to free resources.
myResponse.Close()
Catch ex As WebException
Response.Write(ex.Message)
End Try
End Sub

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top