Page works in IDE but not Compiled (VS2005)

Discussion in 'ASP .Net' started by =?Utf-8?B?RG91Z1Q=?=, Sep 20, 2007.

  1. 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.
     
    =?Utf-8?B?RG91Z1Q=?=, Sep 20, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?RG91Z1Q=?=

    bruce barker Guest

    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)

    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.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.
    >
     
    bruce barker, Sep 20, 2007
    #2
    1. Advertising

  3. 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.ServerCertificateValidationCallback
    >
    >
    > -- 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.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.
    > >

    >
     
    =?Utf-8?B?RG91Z1Q=?=, Sep 20, 2007
    #3
  4. 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.ServerCertificateValidationCallback
    > >
    > >
    > > -- 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.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.
    > > >

    > >
     
    =?Utf-8?B?RG91Z1Q=?=, Sep 24, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Wilson
    Replies:
    4
    Views:
    466
    Jason Wilson
    Jan 31, 2007
  2. philbo30
    Replies:
    5
    Views:
    323
    =?utf-8?B?SGFyYWxkIHZhbiBExLNr?=
    Feb 17, 2007
  3. schmeckel
    Replies:
    9
    Views:
    389
    schmeckel
    Apr 4, 2007
  4. lander
    Replies:
    5
    Views:
    599
    bruce barker
    Mar 5, 2008
  5. FD

    Works in VS2003, but not in VS2005?

    FD, Jun 9, 2006, in forum: ASP .Net Web Services
    Replies:
    4
    Views:
    139
Loading...

Share This Page