473,386 Members | 1,738 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,386 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 2674

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.