Page works in IDE but not Compiled (VS2005)

G

Guest

I have a web page that is using a certificate to interact with another web
site. I'm using ASP.Net in VS 2005. If I run it from the IDE it works great.
If I do a Build/Publish Web Site it doesn't work. I get a "The request was
aborted: Could not create SSL/TLS secure channel." The statement appears
after I perform a datastream = oWebreq.GetRequestStream.

My code looks like the following:
sXml = "xml_data=" & Server.UrlEncode(oXML.InnerXml)
oWebreq = Net.HttpWebRequest.Create(sDSXURL)

oWebreq.ClientCertificates.Add(oCert)
oWebreq.CookieContainer = New Net.CookieContainer
oWebreq.Method = "POST"
oWebreq.AllowWriteStreamBuffering = False
oWebreq.MaximumAutomaticRedirections = 1
oWebreq.AllowAutoRedirect = False
oWebreq.ContentLength = sXml.Length
oWebreq.ContentType = "application/x-www-form-urlencoded"
Try
datastream = oWebreq.GetRequestStream
datastream.Write(System.Text.Encoding.UTF8.GetBytes(sXml),
0, oWebreq.ContentLength)
datastream.Flush()
datastream.Close()
oWebres = oWebreq.GetResponse
Catch ex As Exception
Response.Write(CONFIGPROBLEM & ex.Message)
Exit Sub
End Try

However, it appears something with the certificate, since I have used other
certificates in the code above without problems.
 
B

bruce barker

most likely the server you are requesting has an expired certificate,
which causes the servicepoint manger to rejection the connection. you
can supply your own verification routine. See:

ServicePointManager.ServerCertificateValidationCallback


-- bruce (sqlwork.com)
 
G

Guest

If it was expired why does it work in the VS2005 IDE. I can take that same
certificate export it to a PFX with a password, use that new certificate in
the store and that works.
 
G

Guest

Found the problem. WHen exporting the original certificate a password was not
supplied when request strong encryption. By exporting again and supplying a
password it now works in IDE and runtime.
 

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

No members online now.

Forum statistics

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

Latest Threads

Top