L
leeo
Hi
We're using the following code to send data to a secure server and then
get a response back from it:
System.Net.ServicePointManager.CertificatePolicy = New
cCertificatePolicy
wr = CType(WebRequest.Create(goSettings.NHSDPBClaimsURL),
HttpWebRequest)
nc = New NetworkCredential(goSettings.NHSUserName,
goSettings.NHSPassword)
wr.Credentials = nc
wr.ContentType = "text/xml"
wr.Method = "POST"
xd = New XmlDocument
xd.Load(gsAppPath & "\temp.xml")
xw = New XmlTextWriter(wr.GetRequestStream(), Nothing)
xd.WriteTo(xw)
xw.Close()
ws = CType(wr.GetResponse(), HttpWebResponse) <-- problem
here
sr = ws.GetResponseStream()
rd = New StreamReader(sr)
Now at first we had a hell of a time just being able to connect to the
server until we found some useful tips on google groups about setting
up our own certificate policy which always returns true on the
CheckValidationResult method. This now allows us to send the data to
the server correctly, however when it reaches the line that gets a
reponse from the server, it falls over with the same old "Could not
establish secure channel for SSL/TLS" even though it has clearly run
the new policy and already uploaded data to using the webrequest
object. The strange thing is, if the whole routine is run again by
pressing the send button a second time it works fine.
Does anyone know why we would be getting this problem, or a method to
correct it?
Thanks
Lee
We're using the following code to send data to a secure server and then
get a response back from it:
System.Net.ServicePointManager.CertificatePolicy = New
cCertificatePolicy
wr = CType(WebRequest.Create(goSettings.NHSDPBClaimsURL),
HttpWebRequest)
nc = New NetworkCredential(goSettings.NHSUserName,
goSettings.NHSPassword)
wr.Credentials = nc
wr.ContentType = "text/xml"
wr.Method = "POST"
xd = New XmlDocument
xd.Load(gsAppPath & "\temp.xml")
xw = New XmlTextWriter(wr.GetRequestStream(), Nothing)
xd.WriteTo(xw)
xw.Close()
ws = CType(wr.GetResponse(), HttpWebResponse) <-- problem
here
sr = ws.GetResponseStream()
rd = New StreamReader(sr)
Now at first we had a hell of a time just being able to connect to the
server until we found some useful tips on google groups about setting
up our own certificate policy which always returns true on the
CheckValidationResult method. This now allows us to send the data to
the server correctly, however when it reaches the line that gets a
reponse from the server, it falls over with the same old "Could not
establish secure channel for SSL/TLS" even though it has clearly run
the new policy and already uploaded data to using the webrequest
object. The strange thing is, if the whole routine is run again by
pressing the send button a second time it works fine.
Does anyone know why we would be getting this problem, or a method to
correct it?
Thanks
Lee