Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Using pfx certificate to authenticate a webrequest

Reply
Thread Tools

Using pfx certificate to authenticate a webrequest

 
 
Nelson R.
Guest
Posts: n/a
 
      11-29-2004
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(IAsyncRes ult asyncResult) at
System.Net.HttpWebRequest.GetResponse()....


Can anyone help me about this subject?

Best regards,
Nelson R.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using pfx certificate to authenticate a webrequest Nelson R. ASP .Net 3 03-21-2012 04:50 PM
Importing a .pfx certificate & using it in a stand alone java client Praveen Mohanan Java 3 05-04-2006 06:01 AM
Cisco content switch *.pfx certificate import issue youngy99@gmail.com Cisco 2 06-24-2005 01:49 AM
Using pfx certificate to authenticate a webrequest Nelson Russa ASP .Net Security 0 11-22-2004 09:50 AM
Using pfx certificate to authenticate a webrequest Nelson Russa ASP .Net 0 11-19-2004 03:19 PM



Advertisments