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

Home Posts Topics Members FAQ

HTTPS using VB.NET application

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 HttpWebRequest to send the request across. I get an
exception "Could not establish trust relationship with remote server."
Can anyone guide me as how I can complete this request and get a
response? Do I need to do something to accept all certificates which
come from this server and get on with the application? How do I
accept a certificate that comes to a plain VB.Net application like one
normally does in IE ?

Any help will be greatly appreciated.

Thanks and Regards
Ashu
Jul 21 '05 #1
1 8909
Your lucky, I just blogged about this topic! See
http://weblogs.asp.net/jan/posts/41154.aspx

When Webservices are used, a common concern is security: SOAP messages are
transferred in plain text over the network, so anyone with a sniffer could
intercept the SOAP message and read it. In my opinion this could happen also
to binary data, but probably it requires a little bit more hacker skills. So
a solution is to use HTTPS (SSL) instead of HTTP, so the communication is
encrypted. To accomplish this, you need to get and install a certificate
(issued by a Certificate Authority) on your webserver. In a production
environment you would buy a certificate from Verisign or another well known
CA, or you would install your own CA, which is a component of Windows
Server. If you only want to play with HTTPS, SSL and certificates or your
project is in the development phase, you can also generate a test
certificate using the MakeCert.exe tool (included in the .NET Framework
SDK). After that you have to add this certificate to a website in IIS, and
set a port which HTTPS should use.

When you browse to a HTTPS site, you probably get a dialog window asking you
if you want to trust the certificate provided by the webserver. So the
responsibility of accepting the certificate is handled by the user. Let's
get back to the webservice scenario, if you want to invoke a webservice
located on a webserver which uses SSL and HTTPS there is a problem. When you
make the call from code, there is no dialog window popping up, and asking if
you trust the certificate (luckily because this would be pretty ugly in
server-side scenarios); probably you'll get following exception:
An unhandled exception of type 'System.Net.Web Exception' occurred in
system.dll

Additional information: The underlying connection was closed: Could not
establish trust relationship with remote server.

But there is a solution for this problem, you can solve this in your code by
creating your own CertificatePoli cy class (which implements the
ICertificatePol icy interface). In this class you will have to write your own
CheckValidation Result function that has to return true or false, like you
would press yes or no in the dialog window. For development purposes I've
created the following class which accepts all certificates, so you won't get
the nasty WebException anymore:
public class TrustAllCertifi catePolicy : System.Net.ICer tificatePolicy
{
public TrustAllCertifi catePolicy()
{}

public bool CheckValidation Result(ServiceP oint sp,
X509Certificate cert,WebRequest req, int problem)
{
return true;
}
}

As you can see the CheckValidation Result function always returns true, so
all certificates will be trusted. If you want to make this class a little
bit more secure, you can add additional checks using the X509Certificate
parameter for example. To use this CertificatePoli cy, you'll have to tell
the ServicePointMan ager to use it:
System.Net.Serv icePointManager .CertificatePol icy = new
TrustAllCertifi catePolicy();
This must be done (one time during the application life cycle) before making
the call to your webservice.
--
Greetz,
Jan
_______________ _______________ ____
Read my weblog: http://weblogs.asp.net/jan

"Ashutosh Bhalerao" <as**********@y ahoo.com> schreef in bericht
news:b0******** *************** ***@posting.goo gle.com...
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 HttpWebRequest to send the request across. I get an
exception "Could not establish trust relationship with remote server."
Can anyone guide me as how I can complete this request and get a
response? Do I need to do something to accept all certificates which
come from this server and get on with the application? How do I
accept a certificate that comes to a plain VB.Net application like one
normally does in IE ?

Any help will be greatly appreciated.

Thanks and Regards
Ashu

Jul 21 '05 #2

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

Similar topics

2
2242
by: Rujuta Gandhi | last post by:
Hi All, I am facing a very crucial problem. Im developing a web application using .net studio 2005(beta). I want my Login.aspx page to be secured(https) for encrypted login information transfer. I modified web.config and properties of Login page from IIS server. And now when ever the execution is redirected to Login.aspx It is having https as its protocol.
7
2602
by: Ryan Taylor | last post by:
Hi. I have some code that dynamically generates a PDF and spits this content directly to the web browser. I use HTMLDoc to create the Pdf's from html. So the user can click on a button "Print PDF" and the current page magically becomes a PDF file. This worked great until we moved the site to https. Now, when the button is clicked, I get a warning that This page contains both secure and nonsecure items. Do you want to display the...
1
7739
by: Dees | last post by:
Hi, I am facing a weird problem with HTTPS and Request.Url.AbsoluteUri in my ASP.NET application. Here is the scenario - 1. I have a menu page (Default.aspx), which has the following anchor - <a href="ApplicationHost.aspx">Open Application</a> 2. The ApplicationHost.aspx has the following code in its Load event handler - 'ASSUMPTION -
1
1633
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 HttpWebRequest to send the request across. I get an exception "Could not establish trust relationship with remote server." Can anyone guide me as how I can complete this request and get a response? Do I need to do something to accept all certificates...
2
2899
by: MarkAurit | last post by:
I have a web service Im using on a machine via http in a dmz that works file. Im now attempting to use it in a second server, this one using https. When I attempt to add the Web Reference in vs.net 1.1, I get the following message: ***************************************** There was an error downloading 'https://<dns name>/ScheduledJobs.asmx?op=GetMetrics'. The underlying connection was closed: Unable to connect to the remote server.
4
6531
by: Jason P | last post by:
Basically we have a web method with a dynamic URL. The client is developed in C++ and I've been using the webReference.SetUrl( "http://test.example.com..." ) method successfully with various web method URLs. However, when we switched to using a secure connection, the call to webReference.SetUrl( "https://test.example.com..." ) no longer functions. The SetUrl() method is actually successful, but any following calls in to the web...
4
5055
by: Nader Shahin | last post by:
I tried to develop an application to download a file from an Https server. My application was able to download a file from a regural Http server. I used a WebProxy and i passed the NetworkCredential, but also it didn't work like:- Dim myProxy As New WebProxy("https://TheServername.com/", 443) Also I used that way to create a class to accept all kinds of certifications, and also it didn't work.
2
2601
by: Nader Shahin | last post by:
I tried to develop an application to download a file from an Https server. My application was able to download a file from a regural Http server. I used a WebProxy and i passed the NetworkCredential, but also it didn't work like:- Dim myProxy As New WebProxy("https://TheServername.com/", 443) Also I used that way to create a class to accept all kinds of certifications, and also it didn't work.
4
2103
by: bkasmai | last post by:
My asp.net application (developed using vs2003) runs fine on a windows 2000 server using iis 5.0. Our network manager wants to do away with any http connections and only use https for services that are used by external users. I have not got a clue how to go about this. My users are authenticated directly by querying a sql table where the user names and passwords are stored. What do I need to do to my application or IIS so that internal...
0
9643
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
10313
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
10081
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
8968
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...
0
6735
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.