.NET Compact Framework, WCF Service, DIGEST Compression and Authentication

I am trying to combine a number of functions, which is becoming increasingly difficult due to the limitations of the .NET Compact Framework.

In particular, I have a WCF service, and I am writing a mobile device client for this. Trick? I want to use some kind of data compression (due to a very slow modem connected to the specified device) and HTTP DIGEST authentication (which is already present on the site hosting the WCF service).

I followed this blog post to get the compressed and generated code needed for the WCF service client.

I am, however, struggling with HTTP DIGEST. I do not know how to add this functionality.

I didn’t use compression before, so I connected to the WCF service using SOAP using a simple WebService link, and to add HTTP DIGEST I had to override the GetWebRequest method and manually add the necessary headers. This time around the generated classes, there seems to be very little freedom, and I can't override. In addition, all security or authentication settings appear to be for SSL, and not for such basic authentication schemes.

To summarize: how can I create a WCF client using compression authentication and HTTP DIGEST using the .NET Compact Framework?

EDIT: Here is the code I have received so far:

  System.ServiceModel.Channels.CustomBinding customBinding = new System.ServiceModel.Channels.CustomBinding(); CompressionMessageEncodingBindingElement compressionBindingElement = new CompressionMessageEncodingBindingElement(); customBinding.Elements.Add(compressionBindingElement); HttpTransportBindingElement httpBindingElement = new HttpTransportBindingElement(); customBinding.Elements.Add(httpBindingElement); EndpointAddress endPoint = new EndpointAddress("http://localhost:5100/Service.svc"); ServiceClient client = new ServiceClient(customBinding, endPoint); 

I suspect that I somehow need to add the HTTP DIGEST functionality to the CustomBinding class, but I don't know how to do this.

I suspect I should also note that although I am using the .NET Compact Framework 3.5, I am building a Windows CE application. Thus, I did not download the SDK for Windows Mobile 6. If these SDKs add more features that can be used in Window CE applications and are necessary for HTTP DIGEST to work, let me know.

+4
source share
3 answers

As a result, we disabled DIGEST authentication for devices running .NET CF. This is not so safe, but we thought that the data sent and received by devices running on .NET CF is not so sensitive in our case, so all we really need to do is check it.

+1
source

If the client is running the .NET Compact Framework 3.5, you can use WCF to invoke the service and use the built-in HTTP Digest authentication support without requiring SSL.

Here's how to programmatically configure the WCF client to use Digest authentication with BasicHttpBinding :

 var binding = new BasicHttpBinding(); binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Digest; var endpoint = new EndpointAddress("http://server/myservice"); var client = new MyServiceClient(binding, endpoint); // We have to set the actual credentials on the client proxy object // before invoking the service: client.ClientCredentials.HttpDigest.ClientCredential.UserName = "me"; client.ClientCredentials.HttpDigest.ClientCredential.Password = "password"; try { client.MyServiceOperation(); client.Close(); } catch { client.Abort(); } 

Related Resources:

0
source

The only way to achieve this is to use HttpWebRequest (manually) and specify ClientCredentials instead of the generated classes from NetCFSvcUtil, which does not support authentication. The only WS-Security specification that it supports in CF with WCF is the efficient use of message security with mutual certificate exchange. (Which, incidentally, has a memory leak that I found a colleague: http://connect.microsoft.com/VisualStudio/feedback/details/727247/native-memory-leak-in-wcf-proxy-client-with-mutual- certificate-security-in-net-compact-framework-3-5-on-windows-ce-6-0 )

It should be noted that the generated CFClientBase also has a memory leak that can be circumvented, see http://geekswithblogs.net/GruffCode/archive/2013/03/31/memory-leak-in-cfclientbaselttgt-service-proxy-for-compact -framework-.net.aspx

For reference: a subset of WCF supported by NetCF: http://blogs.msdn.com/b/andrewarnottms/archive/2007/08/21/the-wcf-subset-supported-by-netcf.aspx

0
source

All Articles