tags:

views:

250

answers:

1

I am trying to set up a WCF connection using a certificate on the server for authenticating the server and encrypting data between the client and server.

I have configured the server end like this:

  //  Create the Service
  serviceHost = new ServiceHost(typeof(CIncommingWCFObject));

  //  Now Create the Binding
  NetTcpBinding tcpb = new NetTcpBinding();

  //  Set  the Security to use a certificate for both enctyption and signing...
  tcpb.Security.Mode = SecurityMode.TransportWithMessageCredential;
  tcpb.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
  tcpb.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
  tcpb.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
  serviceHost.AddServiceEndpoint(typeof(IDatabaseServer), tcpb, Params.Uri);

  //  Define the Servers Certificate
  serviceHost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, Params.CertificateName);

  //  And then open the socket...
  serviceHost.Open();

Which does allow the Service to Open.

However, my attempts to define the client end that can connect to this have failed.

Can anyone set me in the right direction?

Kind regards,

Mic

A: 

This article might help:

Fundamentals of WCF Security

rohancragg