Click here to Skip to main content
15,441,629 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Guys,

I am writing a wcf (TCPBinding) test program. I want to make it secured by using TSL.

My server side configuration code is like this:
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Mode = SecurityMode.TransportWithMessageCredential;
tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
                                             StoreName.My,               X509FindType.FindBySubjectName,                                             "ServerCerSubject");
 host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.PeerOrChainTrust;

and my client site configuration is like this:

oBinding = new NetTcpBinding();
           ((NetTcpBinding)oBinding).ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
((NetTcpBinding)oBinding).Security.Mode = SecurityMode.TransportWithMessageCredential;
((NetTcpBinding)oBinding).Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
((NetTcpBinding)oBinding).Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
WCFServer=new ChannelFactory<WCFShared.ITCPServer>(oBinding, new EndpointAddress(UriString));
                         X509FindType.FindBySubjectName, "ClientCerSubject");

I have created the server and client certificate by Makecert.exe

The problem is the client is able to connect to the server even if it uses another certificate!! I mean if I change the client to use another certificate, it still works!

Can someone please tell me what is happening?

I expected that the client certificate should match with the server one that is used by my server application! but It seems that the client certificate is not important! the only thing I have noticed is, the Client needs server certificate to be exist in his trusted people.


1 solution


Could you please have a look at the following article: An easy way to use certificates for WCF security. Looks like it could solve your problem or put some light on the subject?!

Kind regards,
Share this answer
aidin Tajadod 17-May-11 14:40pm     CRLF
Thanks for your reply, Actually I had read that article before, but what he does is a little different from mine! anyway my problem solved! and the reason was Message Credential! I had to specify Message.ClientCredentialType =Certificate! Thanks again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900