![]() |
Page works in IDE but not Compiled (VS2005)
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.GetByte s(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. |
Re: Page works in IDE but not Compiled (VS2005)
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.ServerCertificateValidationCal lback -- bruce (sqlwork.com) DougT wrote: > 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.GetByte s(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. > |
Re: Page works in IDE but not Compiled (VS2005)
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. "bruce barker" wrote: > 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.ServerCertificateValidationCal lback > > > -- bruce (sqlwork.com) > > DougT wrote: > > 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.GetByte s(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. > > > |
Re: Page works in IDE but not Compiled (VS2005)
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. "DougT" wrote: > 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. > > "bruce barker" wrote: > > > 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.ServerCertificateValidationCal lback > > > > > > -- bruce (sqlwork.com) > > > > DougT wrote: > > > 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.GetByte s(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. > > > > > |
| All times are GMT. The time now is 01:28 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.