1

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?

4

1 回答 1

0

问题是 Xamarin 不能很好地与 SSL 或您将与 WCF 一起使用的引用类型一起工作。

最后,我们删除了 WCF 组件并使用了 ASP Web API。

JSON 来回,需要做更多的工作,但它更容易使用/调试,并且碰巧也更交叉兼容。

于 2014-08-25T12:32:23.507 回答