Error when trying to connect over HTTPS using a client certificate.

Discussion in 'ASP .Net' started by Subra Mallampalli, Oct 2, 2003.

  1. Hi,

    I am trying to connect over HTTPS using a client certificate. I am able to
    connect fine when using IE. From my application, however, I get the
    following error:

    The underlying connection was closed: Could not establish secure channel for
    SSL/TLS.
    at System.Net.HttpWebRequest.CheckFinalStatus() at
    System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult) at
    System.Net.HttpWebRequest.GetRequestStream() at Project1.Page_Load(Object
    sender, EventArgs e) in
    d:\temp\vswebcache\myMachine\project1\webform1.aspx.cs:line 47.

    I have installed the certificate on the development machine and the
    certificate has the private key included. From the application, I use a
    DER-encoded X.509 certificate which does not include the private key. I am
    able to read the certificate and its properties from within the application,
    so I know the certificate is fine.

    I am attaching the code that I am using. Any help would be greatly
    appreciated!

    Thanks,

    Subra
    ***************************************************

    ServicePointManager.CertificatePolicy = new CertificatePolicy();
    X509Certificate cert = X509Certificate.CreateFromCertFile(certfile);
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
    req.ClientCertificates.Add(cert);
    req.Method = "POST";
    req.KeepAlive = false;
    req.ContentLength = requestXML.Length;
    Stream reqStream = req.GetRequestStream(); //******** error occurs on this
    line.
    StreamWriter sw = new StreamWriter(reqStream);
    sw.Write(requestXML);
    sw.Close();
    ***************************************************
    Subra Mallampalli, Oct 2, 2003
    #1
    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. Subra Mallampalli
    Replies:
    0
    Views:
    418
    Subra Mallampalli
    Oct 2, 2003
  2. jakecjacobson
    Replies:
    0
    Views:
    226
    jakecjacobson
    Jun 23, 2009
  3. Subra Mallampalli
    Replies:
    0
    Views:
    135
    Subra Mallampalli
    Oct 2, 2003
  4. Subra Mallampalli

    Error when trying to connect over HTTPS using a client certificate.

    Subra Mallampalli, Oct 2, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    123
    Subra Mallampalli
    Oct 2, 2003
  5. William (the Better one)
    Replies:
    1
    Views:
    184
    Roger Pack
    Jul 27, 2010
Loading...

Share This Page