Page works in IDE but not Compiled (VS2005)

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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)
 
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.
 
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.
 
Back
Top