473,419 Members | 4,250 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,419 software developers and data experts.

asp.net client cert issue

Hi all, I have an aspx page that needs to call a remote website that is
protected by client cert authentication. I have installed the client cert
and set permissions for IIS_WPG as per
http://support.microsoft.com/default...b;en-us;817854. I then
exported the cert to a DER encoded file.

Now here is my code:-

Dim h as httpwebrequest
h = Ctype(WebRequest.Create(strurl), httpwebrequest)

Dim mycert as X509Certificate =
X509Certificate.CreateFromCertFile("c:\inetpub\www root\mycert.cer")
h.clientcertificates.add(mycert)

h.contenttype = "text/xml"
h.method = "POST"
h.contentlength = len(strbody)

Dim s as stream = h.getrequeststream()
Dim sw as new streamwriter(s)
sw.write(strbody)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresponse(), httpwebresponse)
Dim s2 as stream = hr.getresponsestream()
Dim sr as new streamreader(s2)
returnstr = sr.readtoend()
sr.close()

Now here is the error I am getting back:-

The underlying connection was closed: Could not establish secure channel for
SSL/TLS.

Any Ideas? Please help. The same code works for a page that is not protected
by Client Certs.

thanks!


Nov 19 '05 #1
3 1472
BTW, the server is 2003 with .net 1.1 sp1 installed.

thanks!

"Param R." <pr@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi all, I have an aspx page that needs to call a remote website that is
protected by client cert authentication. I have installed the client cert
and set permissions for IIS_WPG as per
http://support.microsoft.com/default...b;en-us;817854. I then
exported the cert to a DER encoded file.

Now here is my code:-

Dim h as httpwebrequest
h = Ctype(WebRequest.Create(strurl), httpwebrequest)

Dim mycert as X509Certificate =
X509Certificate.CreateFromCertFile("c:\inetpub\www root\mycert.cer")
h.clientcertificates.add(mycert)

h.contenttype = "text/xml"
h.method = "POST"
h.contentlength = len(strbody)

Dim s as stream = h.getrequeststream()
Dim sw as new streamwriter(s)
sw.write(strbody)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresponse(), httpwebresponse)
Dim s2 as stream = hr.getresponsestream()
Dim sr as new streamreader(s2)
returnstr = sr.readtoend()
sr.close()

Now here is the error I am getting back:-

The underlying connection was closed: Could not establish secure channel
for SSL/TLS.

Any Ideas? Please help. The same code works for a page that is not
protected by Client Certs.

thanks!

Nov 19 '05 #2
Try

h.ContentType = "application/x-www-form-urlencoded";

Eliyahu

"Param R." <pr@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi all, I have an aspx page that needs to call a remote website that is
protected by client cert authentication. I have installed the client cert
and set permissions for IIS_WPG as per
http://support.microsoft.com/default...b;en-us;817854. I then
exported the cert to a DER encoded file.

Now here is my code:-

Dim h as httpwebrequest
h = Ctype(WebRequest.Create(strurl), httpwebrequest)

Dim mycert as X509Certificate =
X509Certificate.CreateFromCertFile("c:\inetpub\www root\mycert.cer")
h.clientcertificates.add(mycert)

h.contenttype = "text/xml"
h.method = "POST"
h.contentlength = len(strbody)

Dim s as stream = h.getrequeststream()
Dim sw as new streamwriter(s)
sw.write(strbody)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresponse(), httpwebresponse)
Dim s2 as stream = hr.getresponsestream()
Dim sr as new streamreader(s2)
returnstr = sr.readtoend()
sr.close()

Now here is the error I am getting back:-

The underlying connection was closed: Could not establish secure channel for SSL/TLS.

Any Ideas? Please help. The same code works for a page that is not protected by Client Certs.

thanks!

Nov 19 '05 #3
Param R. wrote:
Hi all, I have an aspx page that needs to call a remote website that
is protected by client cert authentication. I have installed the
client cert and set permissions for IIS_WPG as per
http://support.microsoft.com/default...b;en-us;817854. I then
exported the cert to a DER encoded file.

Now here is my code:-

Dim h as httpwebrequest
h = Ctype(WebRequest.Create(strurl), httpwebrequest)

Dim mycert as X509Certificate =
X509Certificate.CreateFromCertFile("c:\inetpub\www root\mycert.cer")
h.clientcertificates.add(mycert)

h.contenttype = "text/xml"
h.method = "POST"
h.contentlength = len(strbody)

Dim s as stream = h.getrequeststream()
Dim sw as new streamwriter(s)
sw.write(strbody)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresponse(), httpwebresponse)
Dim s2 as stream = hr.getresponsestream()
Dim sr as new streamreader(s2)
returnstr = sr.readtoend()
sr.close()

Now here is the error I am getting back:-

The underlying connection was closed: Could not establish secure
channel for SSL/TLS.

Any Ideas? Please help. The same code works for a page that is not
protected by Client Certs.


Either the server-side rejected your policy or your current
ICertificatePolicy rejected the server certificate. Verify that both certs
are OK.

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de
Nov 19 '05 #4

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

Similar topics

3
by: EMonaco | last post by:
Is there any way to programmatically select a particular client certificate and associate it with an HttpWebRequest instance? I know using WinINet this was possible. Erin.
1
by: luciano | last post by:
Hi everyone, I want to create a application and a webservice, application connect to web service to activate, web sevice will create a certificate to authenticate this client, for each...
4
by: Matt Frame | last post by:
I am working on a special ASP.Net application that receives files from customers. The connection is made via HTTPS and the client sends the file as a POST to my ASP.Net listener. All of this...
3
by: Tim Burris | last post by:
At the top here i will put a quick description of my problem followed by the long description. This way you want get bored reading! : short version what is the best/recommended way for ASPNET...
1
by: Krishna | last post by:
Well, I got it working when running against my test server (IIS5 W2K svr, I will attach a sample of the code at the bottom of this message), but now I'm connecting to our client (Apache) I'm...
3
by: dinoo | last post by:
I would appreciate if some one answers these queries. Thanks in advance. If My web server is SSL enabled, then why should I havea client certificate authentication? what extra security it...
1
by: Paul NGPC | last post by:
Hi folks This is a challenging and interesting topic. Need HELP on this, would be good if some tips/techniques can be given for the topic. Using VB.NET client to connect to JavaWebserver....
0
by: hepsubah | last post by:
I'm trying to capture a client cert in my ASP.NET application, and use that cert as the client cert for a call to secure web service. I've used the following code, but am getting a 403 error on...
9
by: =?Utf-8?B?U3RldmVuIFRhbmc=?= | last post by:
I want to download pfx from my asp.net server, add the pfx to client's X509Store as a trusted publisher, Is it possible? my func in aspx is like this: void InstallCertification() { try{...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.