473,493 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Posting/Getting with a certificate does not work

I am trying to do a get/post with a certificate to another server to gather
information. I was provided with an ASP example that I am able to get my
results fine with, but when I try it in .NET, the server keeps telling me
there is no certificate. I can check the certificate after loading it using
WSE 2 and it looks fine. Here is the code:
Imports System.Security.Cryptography.X509Certificates
Imports Microsoft.Web.Services2
Imports WseX509 = Microsoft.Web.Services2.Security.X509

Dim url As New Uri("https://server.location.com/Getinfo.asp?id=4")
Dim strXMLResponse

Dim wrequest As HttpWebRequest
Dim wresponse As HttpWebResponse
Dim srequest, sresponse As System.IO.Stream
Dim reader As System.IO.StreamReader
Dim writer As System.IO.StreamWriter
Dim XmlRdr As System.Xml.XmlTextReader
Dim strStatus As String
Dim strReturnMessage As String

Dim doc As XmlDocument = New XmlDocument
Dim nodeList As XmlNodeList
Dim root As XmlElement

Dim certStore As WseX509.X509CertificateStore =
WseX509.X509CertificateStore.LocalMachineStore(Wse X509.X509CertificateStore.MyStore)
Dim open As Boolean = certStore.OpenRead()
Dim cert2 = GetCertificate("MyCertDescription", certStore)

wrequest = CType(WebRequest.Create(url), HttpWebRequest)
With wrequest
.Method = "GET"
.Timeout = 50000
.ClientCertificates.Add(cert2)
.KeepAlive = False
End With

'get the response from the request
wresponse = CType(wrequest.GetResponse(), HttpWebResponse)
ResponseStream = wresponse.GetResponseStream
'Hook up a streamreader to the stream for ease of reading
ResponseStreamReader = New System.IO.StreamReader(ResponseStream)
strXMLResponse = ResponseStreamReader.ReadToEnd()
Their server responds back in the XML response indicating the cert wasn't
present. The company I am working with has told me I'm the only one trying
it in .NET - everyone else uses ASP so they are no help. I don't know if
there is a difference between using ASP and ASP.NET for cert passing - I
would doubt it but I just don't know what the problem is.
Nov 22 '05 #1
1 2069
After bouncing around Microsoft's support line for a while, it turns out that
my dev machine was NOT running SP1 for the .NET Framework 1.1.

If you do not have SP1 installed, your web service call will not pass the
certificate along as it cannot access the local machine store properly. KB
alert # 901183 mentions you need SP1 and now I know why. It will look like
it was passing it, but doesn't.

Cheers!

"Jeff Fulcer" wrote:
I am trying to do a get/post with a certificate to another server to gather
information. I was provided with an ASP example that I am able to get my
results fine with, but when I try it in .NET, the server keeps telling me
there is no certificate. I can check the certificate after loading it using
WSE 2 and it looks fine. Here is the code:
Imports System.Security.Cryptography.X509Certificates
Imports Microsoft.Web.Services2
Imports WseX509 = Microsoft.Web.Services2.Security.X509

Dim url As New Uri("https://server.location.com/Getinfo.asp?id=4")
Dim strXMLResponse

Dim wrequest As HttpWebRequest
Dim wresponse As HttpWebResponse
Dim srequest, sresponse As System.IO.Stream
Dim reader As System.IO.StreamReader
Dim writer As System.IO.StreamWriter
Dim XmlRdr As System.Xml.XmlTextReader
Dim strStatus As String
Dim strReturnMessage As String

Dim doc As XmlDocument = New XmlDocument
Dim nodeList As XmlNodeList
Dim root As XmlElement

Dim certStore As WseX509.X509CertificateStore =
WseX509.X509CertificateStore.LocalMachineStore(Wse X509.X509CertificateStore.MyStore)
Dim open As Boolean = certStore.OpenRead()
Dim cert2 = GetCertificate("MyCertDescription", certStore)

wrequest = CType(WebRequest.Create(url), HttpWebRequest)
With wrequest
.Method = "GET"
.Timeout = 50000
.ClientCertificates.Add(cert2)
.KeepAlive = False
End With

'get the response from the request
wresponse = CType(wrequest.GetResponse(), HttpWebResponse)
ResponseStream = wresponse.GetResponseStream
'Hook up a streamreader to the stream for ease of reading
ResponseStreamReader = New System.IO.StreamReader(ResponseStream)
strXMLResponse = ResponseStreamReader.ReadToEnd()
Their server responds back in the XML response indicating the cert wasn't
present. The company I am working with has told me I'm the only one trying
it in .NET - everyone else uses ASP so they are no help. I don't know if
there is a difference between using ASP and ASP.NET for cert passing - I
would doubt it but I just don't know what the problem is.

Nov 22 '05 #2

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

Similar topics

0
1786
by: Tetedeiench | last post by:
Hi ! I am currently changing the server for my website, and i make a heavy use of openssl functions. Both servers use PHP4.3.3 with OpenSSL 0.9.6i. I was actually testing with this code,...
2
8270
by: Robin H. Johnson | last post by:
Hi, I'm working on a project making large use of OpenSSL to individually encrypt items inside a database, but I've hit a stumbling block. There appears to be absolutely no native PHP way (eg...
0
7545
by: Mishi Abolghasem | last post by:
I'm trying to use this sequence of VB-API calls to post to a web-page where client certificate is required.( InternetOpen,InternetConnect,HttpOpenRequest,HttpSendRequest) And then InternetReadFile...
1
429
by: Jeff Fulcer | last post by:
I am trying to do a get/post with a certificate to another server to gather information. I was provided with an ASP example that I am able to get my results fine with, but when I try it in .NET,...
4
11309
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...
7
1804
by: Dave | last post by:
Is it difficult to write a program that, given an array of URLs, will probe each one, and return a status of Found or Not Found? How would you approach it? While Googling, I found utility after...
3
9920
by: JerryK | last post by:
Hi, I have an ASP.net page, written in VB.net. In that code I want to access a validator web services that is secured via SSL. I have installed the certificate, via a .pfx file, on the system....
1
2965
by: romiko2000 | last post by:
Hi Folks, I got a weird problem, I create an XMLWriter to post a document via the webrequest stream and after running a network trace, I notice the data is prefixed with 3 invalid characters! ...
1
1621
by: UnkleVo | last post by:
I have a winform app that is consuming WebService via SSL connection. We installed the digital certificate for that and the winform app is loading that cert at run time. Code in VB.net looks...
1
5892
by: Joe | last post by:
Hello, I'm currently using a C# class library which is also converted quickly to a console app by adding a MAIN and adjusting the building configuration. I'm using this page as a reference to the...
0
7195
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...
1
6873
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
7367
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
5453
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,...
1
4889
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...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
285
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...

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.