Webresponse/SSL Problems

nod

Member
Joined
Nov 26, 2006
Messages
5
Programming Experience
Beginner
I am new to VB.NET and am trying to check the status of my sites. I have created a funciton to do this for me. It works fine but I get the Site Cert which comes up. I am trying to work around that with a different Function which installs the Certificate. Here is the code that I am using: Some of it is sample stuff but should not cause any headaches.

Try
' Set up the request
Dim _httpRequest As HttpWebRequest = CType(System.Net.WebRequest.Create(_Uri), HttpWebRequest)
' Load the certificate into an X509Certificate object.
Dim Certificate As X509Certificate = X509Certificate.CreateFromCertFile("c:\cert.cer")
' Get the value.
Dim results As String = Certificate.GetCertHashString()
_httpRequest.ClientCertificates.Add(Certificate)
'_Uri)
' get the response object
Dim _httpResponse As HttpWebResponse = CType(_httpRequest.GetResponse, HttpWebResponse)
Dim stream As Stream = Nothing
Dim reader As StreamReader = Nothing
Dim writer As StreamWriter = Nothing
Try
stream = _httpResponse.GetResponseStream
reader =
New StreamReader(stream, Encoding.UTF8)
MessageBox.Show(_httpResponse.StatusCode)
Return _httpResponse.StatusCode
Finally
' Allways close all streams
stream.Close()
reader.Close()
writer.Close()
End Try
Catch ex As Exception
MessageBox.Show(ex.Message,
"error")
'Throw ex
End Try

I'm pulling my hair out!
 
Back
Top