Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access secure web site using WINHTTP

Status
Not open for further replies.

nomi2000

ISP
Feb 15, 2001
676
CA
Hi guys i wrote down the following code to connect to a secure web site using WINHTTP,but i am getting "security error",although i can access some other websites with this code but when i am trying to connect to Secure Web Site with the client certificate i am getting the above error..
Thanks
Nouman

ERROR
=====
System.Runtime.InteropServices.COMException (0x80072F8F): A security error occurred
at WinHttp.WinHttpRequestClass.Send(Object Body)
at SOAPWebApp.WebForm1.btnTest_Click(Object sender, EventArgs e) in C:\Inetpub\ 118

CODE
====
Try
Dim sss As String = ""
Dim HttpReq As New WinHttp.WinHttpRequest
' Open an HTTP connection.
HttpReq.Open("PUT", " False)
If Trim(txtUsername.Text) <> "" And Trim(txtPassword.Text) <> "" Then
HttpReq.SetCredentials(Trim(txtUsername.Text), Trim(txtPassword.Text), 0)
End If
' Select the client certificate.
HttpReq.Option(WinHttp.WinHttpRequestOption.WinHttpRequestOption_SelectCertificate) = "LOCAL_MACHINE\My\Joe's-Software-Emporium"
HttpReq.SetClientCertificate("LOCAL_MACHINE\My\Joe's-Software-Emporium")
' Set Header for SOAP Action
HttpReq.SetRequestHeader("SOAPAction", " HttpReq.SetRequestHeader("Content-Type", "text/xml; charset=utf-8") 'FOR SOAP
HttpReq.SetRequestHeader("Content-Length", Len(sss))
' Send the HTTP Request.
HttpReq.Send()
TextBox1.Text = HttpReq.ResponseText
Catch exp As Exception
TextBox1.Text = "Error Occurred : " & exp.Message & vbCrLf & vbCrLf & exp.GetBaseException.ToString
End Try


Nouman Zaheer
Software Engineer
MSR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top