/// <summary> /// Can only call before using the proxy for the first time /// </summary> public static void SecureProxy <T>(this ClientBase <T> proxy, StoreLocation storeLocation, StoreName storeName, X509FindType findType, string clientCertificateName) where T : class { if (proxy.State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } SetCertificate(proxy, storeLocation, storeName, findType, clientCertificateName); ServiceEndpoint[] endpoints = { proxy.Endpoint }; proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust; SecurityBehavior.ConfigureBusinessToBusiness(endpoints); }
public void SetCredentials(StoreLocation storeLocation, StoreName storeName, X509FindType findType, string clientCertificateName) { if (State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } Credentials.ClientCertificate.SetCertificate(storeLocation, storeName, findType, clientCertificateName); Collection <ServiceEndpoint> endpoints = new Collection <ServiceEndpoint>(); endpoints.Add(Endpoint); SecurityBehavior.ConfigureBusinessToBusiness(endpoints); }
public static void SetCredentials <T>(this ChannelFactory <T> factory, StoreLocation storeLocation, StoreName storeName, X509FindType findType, string clientCertificateName) { if (factory.State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } factory.Credentials.ClientCertificate.SetCertificate(storeLocation, storeName, findType, clientCertificateName); Collection <ServiceEndpoint> endpoints = new Collection <ServiceEndpoint>(); endpoints.Add(factory.Endpoint); SecurityBehavior.ConfigureBusinessToBusiness(endpoints); factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust; }