I have a WCF service on a development server (IIS). The service has a self signed SSL and username authentication enabled on it.
I've setup a test ASP MVC project that can successfully call data from the service like so:
CategoryServiceClient csc = new CategoryServiceClient();
csc.ClientCredentials.UserName.UserName = "Username";
csc.ClientCredentials.UserName.Password = "Password";
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
var a = csc.GetCategories();
While I'm using a self signed certificate the call to ServicePointManager.ServerCertificateValidationCallback
works in this instance.
The problem is that I want to use this service for a Xamarin project which requires me to use the SlSvcUtil.exe to build the client side code.
In the command prompt I navigate to the SLSvcUtil directory:
cd C:\Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Tools
Then I run this cmd to generate the code docs:
SlSvcUtil.exe https://x.x.x.x:2022/CategoryService.svc /directory:"c:\Users\Shaun\Desktop\Services"
This fails with the following error:
The underlying connection was closed: Could not establish trust relationship for the SSL/TSL secure channel.
How can I run this command without the validation check or automatically pass the validation like my code sample?
-or-
How can I use Xamarin to generate a service reference for a WCF service that is using SSL?
-or-
How can I make my self signed (development) SSL cert be able to establish a trust relationship?