473,782 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(WebReques t.Create(strurl ), httpwebrequest)

Dim mycert as X509Certificate =
X509Certificate .CreateFromCert File("c:\inetpu b\wwwroot\mycer t.cer")
h.clientcertifi cates.add(mycer t)

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

Dim s as stream = h.getrequeststr eam()
Dim sw as new streamwriter(s)
sw.write(strbod y)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresp onse(), httpwebresponse )
Dim s2 as stream = hr.getresponses tream()
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 1489
BTW, the server is 2003 with .net 1.1 sp1 installed.

thanks!

"Param R." <pr@nospam.co m> wrote in message
news:%2******** ********@TK2MSF TNGP11.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(WebReques t.Create(strurl ), httpwebrequest)

Dim mycert as X509Certificate =
X509Certificate .CreateFromCert File("c:\inetpu b\wwwroot\mycer t.cer")
h.clientcertifi cates.add(mycer t)

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

Dim s as stream = h.getrequeststr eam()
Dim sw as new streamwriter(s)
sw.write(strbod y)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresp onse(), httpwebresponse )
Dim s2 as stream = hr.getresponses tream()
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 = "applicatio n/x-www-form-urlencoded";

Eliyahu

"Param R." <pr@nospam.co m> wrote in message
news:%2******** ********@TK2MSF TNGP11.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(WebReques t.Create(strurl ), httpwebrequest)

Dim mycert as X509Certificate =
X509Certificate .CreateFromCert File("c:\inetpu b\wwwroot\mycer t.cer")
h.clientcertifi cates.add(mycer t)

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

Dim s as stream = h.getrequeststr eam()
Dim sw as new streamwriter(s)
sw.write(strbod y)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresp onse(), httpwebresponse )
Dim s2 as stream = hr.getresponses tream()
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(WebReques t.Create(strurl ), httpwebrequest)

Dim mycert as X509Certificate =
X509Certificate .CreateFromCert File("c:\inetpu b\wwwroot\mycer t.cer")
h.clientcertifi cates.add(mycer t)

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

Dim s as stream = h.getrequeststr eam()
Dim sw as new streamwriter(s)
sw.write(strbod y)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresp onse(), httpwebresponse )
Dim s2 as stream = hr.getresponses tream()
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
ICertificatePol icy 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
12940
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
1849
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 transaction between client anh server, server will check cerfiticate of client connect to it. How do i do that? Thanks for your reply.
4
11329
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 works fine. Now I am looking at how to validate the clients certificate programmatically. The client application sends to me with something like: .... Dim myHttp As HttpWebRequest = CType(WebRequest.Create(https://myserver/Receive.aspx),...
3
2821
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 apps to call web services that REQUIRE Client Certificates via SSL long version our company has new requirements, all servers must REQUIRE SSL and Server/client certificates i have setup a test Win2003 server to issue certs so i have a full test...
1
2942
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 getting the following error: An unhandled exception of type 'System.Net.WebException' occurred in system.dll Additional information: The underlying connection was closed: Unable to connect to the remote server.
3
1982
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 provides? Can I use client certificate without having SSL connection? How do I get the Client Certificate? Is it necessary to be issued from the same webservice server i want to use? Or I can get it from any CA e.g verisign? Is it possible to get free...
1
3289
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. Don't know how to use the 2-way SSL to communicate and make the SSL handshake process( at Transport level https://) transparent. Any .NET classes to make all the 2-way SSL
0
1486
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 the invocation of the service. All the service is supposed to do is return the subject of the passed cert (I'll do more with it later) ...
9
7272
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{ WebClient web = new WebClient(); string url = "http:/myaspserver/mydir/mykey_2008.pfx"; byte b = web.DownloadData(url);
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8967
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7492
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.