Hi everybody,
my VB.NET (Framework 2.0) client application has to do a HttpWebRequest (for
reading web-pages and downloading files) on a web server. The server uses a
self-signed certifiacte and the client application should also use a
self-signed certificate (of course, signed by the same self-made CA) so we
would have an authentication of both directions: the server to the client
and the other way round.
Is there a way to programmatically load the self-signed server certificate
in my VB application? Something like:
Private _WebClient As HttpWebRequest
Private _ClientCert As X509Certificate2 = LoadCert() ' This already works
_WebClient = CType(WebRequest.Create(_Server + "site.html"), HttpWebRequest)
_WebClient.ClientCertificates.Add(_ClientCert)
' Something like this.....
_WebClient.AuthorizedCertificateAuthorities.Add("M yCA.crt")
Dim NewResponse As HttpWebResponse = CType(_WebClient.GetResponse(),
HttpWebResponse)
So far my client does not accept the server certificate since it could not
establish the trust relationship! Of course, since my client does not know
about the CA. And I don't want to have to install the certificate/CA on each
machine that I need to install the software on.
Any ideas?
Thank you very much,
Josef 2 12905
Hello,
Here is a sample may help:
HttpWebRequest httprq = (HttpWebRequest)HttpWebRequest.Create(uri);
httprq.Method = "POST";
httprq.ContentType = "text/xml; charset=utf-8";
string certificateName = "ABC";
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates =
store.Certificates.Find(X509FindType.FindBySubject Name, certificateName,
true);
X509Certificate certificate = certificates[0];
httprq.ClientCertificates.Add(certificate);
//Response
HttpWebResponse httprp = (HttpWebResponse)httprq.GetResponse();
Also, The server certificate's root authority must be trusted by client and
the client certificate's root authority must be trusted by the server.
Regards,
Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Luke,
thanks for the advice with the certificat sore. What I'm trying to do write
know is to load all certificates (client, server, ca) into the corresponding
certificate stores. But
1. I still get the ..."Could not establish trust relationship for the
SSL'/TLS secure channel" error message
2. I cannot find the certificates I just added to the differen certificate
stores wihin the IE...
Here's the code...maybe I do something wrong while adding them...
Private _ClientCert As X509Certificate2
Private _ServerCert As X509Certificate2
Private _CACert As X509Certificate2
Public Sub New(ByVal ClientCertFile As String, ByVal ServerCertFile As
String, ByVal CACertFile As String)
_ClientCert = ReadCertificate(ClientCertFile)
_ServerCert = ReadCertificate(ServerCertFile)
_CACert = ReadCertificate(CACertFile)
Dim CAstore As New X509Store(StoreName.CertificateAuthority,
StoreLocation.LocalMachine)
CAstore.Open(OpenFlags.ReadWrite)
CAstore.Add(_CACert)
CAstore.Close()
Dim ServerStore As New X509Store(StoreName.TrustedPeople,
StoreLocation.LocalMachine)
ServerStore.Open(OpenFlags.ReadWrite)
ServerStore.Add(_ServerCert)
ServerStore.Close()
Dim ClientStore As New X509Store(StoreName.My, StoreLocation.LocalMachine)
ClientStore.Open(OpenFlags.ReadWrite)
ClientStore.Add(_ClientCert)
ClientStore.Close()
Thanx,
Josef This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steven Pu |
last post by:
Hi,
Specifically, the website I am trying to access is,
https://gmail.google.com/
I've read elsewhere that Google only uses SSL2, while .NET uses SSL3
and is not backward compatible. Is...
|
by: Soeren S. Joergensen |
last post by:
Hi,
From a win-service I do a HttpWebRequest to a secure url with some
parameters to get some simple data from a remote system used later on in a
worker thread.
When making the request from...
|
by: Deepak |
last post by:
We retrieve data from a company called XYZ through httpwebrequest.
The program is coded using VB.NET
They have given a certificate to install.
This certificate is included with the request...
|
by: Josef Brunner |
last post by:
Hi everybody,
my VB.NET (Framework 2.0) client application has to do a HttpWebRequest (for
reading web-pages and downloading files) on a web server. The server uses a
self-signed certifiacte and...
|
by: steveS |
last post by:
Hi all,
I'm having trouble connecting to a Java web service using HttpWebRequest. I
get the error message "The request was aborted: Could not create SSL/TLS
secure channel". The Java service...
|
by: steveS |
last post by:
Hi all,
I'm having trouble connecting to a Java web service using HttpWebRequest. I
get the error message "The request was aborted: Could not create SSL/TLS
secure channel". The Java service...
|
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...
|
by: nomad |
last post by:
Hi,
I am using HTTPWebRequest to add a client certificate. I am then
using HTTPWebRequest to POST xml to a web service which requires the
attached client certificate to authenticate with their...
|
by: am1974po |
last post by:
I have 2 applications:
One is simple windows application and the other is web service.
They are both on the same machine, windows server 2003 - SP2.
exactly the same code in both:...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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: 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,...
| |