Using pfx certificate to authenticate a webrequest

Discussion in 'ASP .Net Security' started by Nelson R., Nov 29, 2004.

  1. Nelson R.

    Nelson R. Guest

    Hi,

    i need to get some info from a website page that requires an
    certificate.

    Ive got the provided certificate installed in IE, and when accessing
    the website page, it shows a window to select the client certificate
    and then shows the page correctly.

    Im trying to do this by code (C# aspnet), using webrequest.

    The certificate is in an pfx file and does not require password. I've
    exported the file using IE to DER encoded binary X.509 (.cer).

    My code:

    X509Certificate certificate =
    X509Certificate.CreateFromCertFile(Server.MapPath("file.cer"));
    HttpWebRequest req =
    (HttpWebRequest)WebRequest.Create("https://websiteurl");
    req.Method="POST";
    req.ClientCertificates.Add(certificate);

    HttpWebResponse result = (HttpWebResponse) req.GetResponse();
    ReceiveStream = result.GetResponseStream();
    // ...
    // ...


    I got this error:

    System.Net.WebException: The underlying connection was closed: Could
    not establish secure channel for SSL/TLS. --->
    System.ComponentModel.Win32Exception: The message received was
    unexpected or badly formatted at
    System.Net.TlsStream.EndRead(IAsyncResult asyncResult) at
    System.Net.Connection.ReadCallback(IAsyncResult asyncResult) --- End
    of inner exception stack trace --- at
    System.Net.HttpWebRequest.CheckFinalStatus() at
    System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at
    System.Net.HttpWebRequest.GetResponse()....


    Can anyone help me about this subject?

    Best regards,
    Nelson R.
     
    Nelson R., Nov 29, 2004
    #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. Nelson Russa
    Replies:
    0
    Views:
    589
    Nelson Russa
    Nov 19, 2004
  2. Nelson R.
    Replies:
    3
    Views:
    8,274
    rmacone
    Mar 21, 2012
  3. Praveen Mohanan
    Replies:
    3
    Views:
    5,168
    Tony Morris
    May 4, 2006
  4. Nelson Russa

    Using pfx certificate to authenticate a webrequest

    Nelson Russa, Nov 22, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    188
    Nelson Russa
    Nov 22, 2004
  5. Certificate Authenticate

    , May 2, 2005, in forum: Perl Misc
    Replies:
    0
    Views:
    109
Loading...

Share This Page