ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = true;
serviceHost.Description.Behaviors.Add(behavior);
serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
httpBinding.Security.Message.ClientCredentialType=BasicHttpMessageCredentialType.Certificate;
serviceHost.Credentials.ClientCertificate.Authentication.CertificateValidationMode=X509CertificateValidationMode.Custom;
serviceHost.Credentials.ClientCertificate.Authentication.CustomCertificateValidator = new CertValidator();