G
Guest
I am trying to do a get/post with a certificate to another server to gather
information. I was provided with an ASP example that I am able to get my
results fine with, but when I try it in .NET, the server keeps telling me
there is no certificate. I can check the certificate after loading it using
WSE 2 and it looks fine. Here is the code:
Imports System.Security.Cryptography.X509Certificates
Imports Microsoft.Web.Services2
Imports WseX509 = Microsoft.Web.Services2.Security.X509
Dim url As New Uri("https://server.location.com/Getinfo.asp?id=4")
Dim strXMLResponse
Dim wrequest As HttpWebRequest
Dim wresponse As HttpWebResponse
Dim srequest, sresponse As System.IO.Stream
Dim reader As System.IO.StreamReader
Dim writer As System.IO.StreamWriter
Dim XmlRdr As System.Xml.XmlTextReader
Dim strStatus As String
Dim strReturnMessage As String
Dim doc As XmlDocument = New XmlDocument
Dim nodeList As XmlNodeList
Dim root As XmlElement
Dim certStore As WseX509.X509CertificateStore =
WseX509.X509CertificateStore.LocalMachineStore(WseX509.X509CertificateStore.MyStore)
Dim open As Boolean = certStore.OpenRead()
Dim cert2 = GetCertificate("MyCertDescription", certStore)
wrequest = CType(WebRequest.Create(url), HttpWebRequest)
With wrequest
.Method = "GET"
.Timeout = 50000
.ClientCertificates.Add(cert2)
.KeepAlive = False
End With
'get the response from the request
wresponse = CType(wrequest.GetResponse(), HttpWebResponse)
ResponseStream = wresponse.GetResponseStream
'Hook up a streamreader to the stream for ease of reading
ResponseStreamReader = New System.IO.StreamReader(ResponseStream)
strXMLResponse = ResponseStreamReader.ReadToEnd()
Their server responds back in the XML response indicating the cert wasn't
present. The company I am working with has told me I'm the only one trying
it in .NET - everyone else uses ASP so they are no help. I don't know if
there is a difference between using ASP and ASP.NET for cert passing - I
would doubt it but I just don't know what the problem is.
information. I was provided with an ASP example that I am able to get my
results fine with, but when I try it in .NET, the server keeps telling me
there is no certificate. I can check the certificate after loading it using
WSE 2 and it looks fine. Here is the code:
Imports System.Security.Cryptography.X509Certificates
Imports Microsoft.Web.Services2
Imports WseX509 = Microsoft.Web.Services2.Security.X509
Dim url As New Uri("https://server.location.com/Getinfo.asp?id=4")
Dim strXMLResponse
Dim wrequest As HttpWebRequest
Dim wresponse As HttpWebResponse
Dim srequest, sresponse As System.IO.Stream
Dim reader As System.IO.StreamReader
Dim writer As System.IO.StreamWriter
Dim XmlRdr As System.Xml.XmlTextReader
Dim strStatus As String
Dim strReturnMessage As String
Dim doc As XmlDocument = New XmlDocument
Dim nodeList As XmlNodeList
Dim root As XmlElement
Dim certStore As WseX509.X509CertificateStore =
WseX509.X509CertificateStore.LocalMachineStore(WseX509.X509CertificateStore.MyStore)
Dim open As Boolean = certStore.OpenRead()
Dim cert2 = GetCertificate("MyCertDescription", certStore)
wrequest = CType(WebRequest.Create(url), HttpWebRequest)
With wrequest
.Method = "GET"
.Timeout = 50000
.ClientCertificates.Add(cert2)
.KeepAlive = False
End With
'get the response from the request
wresponse = CType(wrequest.GetResponse(), HttpWebResponse)
ResponseStream = wresponse.GetResponseStream
'Hook up a streamreader to the stream for ease of reading
ResponseStreamReader = New System.IO.StreamReader(ResponseStream)
strXMLResponse = ResponseStreamReader.ReadToEnd()
Their server responds back in the XML response indicating the cert wasn't
present. The company I am working with has told me I'm the only one trying
it in .NET - everyone else uses ASP so they are no help. I don't know if
there is a difference between using ASP and ASP.NET for cert passing - I
would doubt it but I just don't know what the problem is.