473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Using pfx certificate to authenticate a webrequest

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);

// ...
// here goes the request response read
// ...
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 about this subject? Is this the right newsgroup for
this kind of questions, or should i post in security group?

Best regards,
Nelson Russa
Nov 18 '05 #1
0 2671

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ashutosh Bhalerao | last post by:
Hi all, I am trying to write a VB.Net application which communicates over SSL with an IIS server. I have got a temporary certificate from Verisign and installed it on IIS. I am using...
0
by: Subra Mallampalli | last post by:
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...
1
by: Nelson R. | last post by:
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...
3
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication...
1
by: Shelby | last post by:
Hi, I'm doing some research on webservices using 2 way SSL. It is Application-to-Application security. Basically SERVER_SAP is hosting the webservice and SERVER_CLIENT is consuming the...
5
by: | last post by:
Hi all, HttpWebRequest, and SoapHttpClientProtocol both expose a ClientCertificates property, which can hold multiple client certificates, but on the service side, it can only receive one client...
0
by: Anonieko | last post by:
..NET 1.0 /1.1 version: ====================== using System.Net; using System.Security.Cryptography.X509Certificates; // ... private void MethodToAccessSSL() {
0
by: Medtondo | last post by:
I have an app that uses the events in IE (SHDocVw). I can get the DownloadComplete event etc working well, but what I would like to do is get the SSL key that IE is using for the session. What I...
0
by: BillE | last post by:
VS2005 VB.net I'm using the HTTPWebRequest class to connect to a web site with SSL. I first manually connected to the site and installed the certificate on my computer, and then use the...
0
by: xievvv | last post by:
I am trying to have a SslStream client and an SslStream server mutually authenticate and communicate with each other, over TCP. So when I call the methods AuthenticateAsClient() and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.