VB.NET http web request with client certificate


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
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top