Отвечаю сам себе
WSDualHttpBinding binding = new WSDualHttpBinding(WSDualHttpSecurityMode.Message);
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
binding.MaxReceivedMessageSize = Int32.MaxValue;
// ищем cертификат .cer для сервера в TrustedPeople
X509Certificate2 cert = null;
X509Store certStore = new X509Store(StoreName.TrustedPeople, StoreLocation.CurrentUser);
certStore.Open(OpenFlags.ReadOnly);
for (int i = 0; i < certStore.Certificates.Count; i++)
if (certStore.Certificates[i].SubjectName.Name == "CN=testsvc")
cert = certStore.Certificates[i];
certStore.Close();
// указываем identity по сертификату
X509CertificateEndpointIdentity identity = new X509CertificateEndpointIdentity(cert);
// адрес
EndpointAddress addr = new EndpointAddress(new Uri("http://localhost:999/ServiceAdmin"),
identity,
new AddressHeaderCollection());
// это коллбек
_ClientCallback = new ServiceAdminCallback();
// это клиент
Client = new ServiceAdminClient(new InstanceContext(_ClientCallback),
binding,
addr);
Client.ClientCredentials.UserName.UserName = _LastUser;
Client.ClientCredentials.UserName.Password = _LastPassword;
Вот так. И никаких конфигов ;) PS. В этом примере реализовано только шифрование сообщений серверу