VB.NET http web request with client certificate

  • Thread starter Thread starter Adriano
  • Start date Start date
A

Adriano

Hello!

I need to send simple web request to a server that have network
credentials + requires client certificate. I used the following code for
network credentials, what should I do next to pass client certificate?

Dim myURL As String = "https://someurl:portno"
Try
Dim request As HttpWebRequest
request = HttpWebRequest.Create(myURL)
request.Credentials = New Net.NetworkCredential("user", "pass")

Dim response As HttpWebResponse =
CType(request.GetResponse(), HttpWebResponse)
'Read Data Stream
Dim dataStream As Stream = response.GetResponseStream
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
Console.WriteLine(responseFromServer)
Catch ex As Exception
MsgBox(Err.Description & vbCrLf & myURL)
End Try



Thanks in advance!

Adriano
 
Back
Top