HTTPS SSL .Net webservice

jhomminga

Active member
Joined
Jan 17, 2007
Messages
37
Programming Experience
5-10
Looking for a complete working example(asmx, classes, and a test client snippet
icon11.gif
). I am having trouble and need some expertise.

I have external clients (read I have no control and they won't let me help them) to call into a web service running under SSL on IIS.

I want to rig the webservice to be quiet and politely do SSL without dropping connections or stop listening.

Does anyone have an webservice example of how to use this
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

I found a couple of great links but can't get it to work
http://www.dotnetforums.net/t80674.html
http://weblogs.asp.net/jan/archive/2003/12/04/41154.aspx (gotta scroll through the spam comments)
http://www.supinfo-projects.com/en/2005/webserviceshttpsen/2/
http://msdn2.microsoft.com/en-us/library/aa395197.aspx


If I am not on the right track any guidance is much appreciated
 
Example

Got the answer here. Since I had put a test certificate and not an authentic one on the test server, all non-local machine calls were blocked.

http://msdn2.microsoft.com/en-us/library/aa730835(vs.80).aspx

As long as this is in the client class (mine are shared for testing)
VB.NET:
Imports System
Imports System.Net
Imports System.Text
Imports System.Net.Sockets
Imports System.Net.Security
Imports System.Security.Authentication
Imports System.Security.Cryptography.X509Certificates

 
    Public Shared Function SomeCertificateValidation(ByVal sender As Object, 
                                                     ByVal TheCert As X509Certificate, 
                                                     ByVal TheChain As X509Chain, 
                                                     ByVal TheErrors As SslPolicyErrors) As Boolean
        Return True
    End Function

Then in each method in client class have this(could have just been in the constructor of instance class)
VB.NET:
Public Shared Sub HelloWorldTest()
        ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf SomeCertificateValidation)

And then it gets called automatically, there is no wiring up needed. Pretty cool, must read more to learn how it works.

Details are here
http://msdn2.microsoft.com/en-us/li...ager.servercertificatevalidationcallback.aspx
 
Back
Top