Problems with Security Certificates and Secure Servers

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
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top