/// <summary> /// Can only call before using the proxy for the first time /// </summary> public static void UnsecuredProxy <T>(this ClientBase <T> proxy) where T : class { if (proxy.State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } ServiceEndpoint[] endpoints = { proxy.Endpoint }; SecurityBehavior.ConfigureNone(endpoints); }
/// <summary> /// Can only call before using the proxy for the first time /// </summary> public static void UnsecuredProxy<T>(ClientBase<T> proxy) where T : class { if(proxy.State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } Collection<ServiceEndpoint> endpoints = new Collection<ServiceEndpoint>(); endpoints.Add(proxy.Endpoint); SecurityBehavior.ConfigureNone(endpoints); }
public static void SetSecurityMode <T, C>(this DuplexChannelFactory <T, C> factory, ServiceSecurity mode) where T : class { switch (mode) { case ServiceSecurity.None: { if (factory.State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } Collection <ServiceEndpoint> endpoints = new Collection <ServiceEndpoint>(); endpoints.Add(factory.Endpoint); SecurityBehavior.ConfigureNone(endpoints); break; } case ServiceSecurity.Anonymous: { if (factory.State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } Collection <ServiceEndpoint> endpoints = new Collection <ServiceEndpoint>(); endpoints.Add(factory.Endpoint); SecurityBehavior.ConfigureAnonymous(endpoints); factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust; break; } default: { throw new InvalidOperationException(mode + " is unsupported with this constructor"); } } }
public void SetSecurityMode(ServiceSecurity mode) { switch (mode) { case ServiceSecurity.None: { if (State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } Collection <ServiceEndpoint> endpoints = new Collection <ServiceEndpoint>(); endpoints.Add(Endpoint); SecurityBehavior.ConfigureNone(endpoints); break; } case ServiceSecurity.Anonymous: { if (State == CommunicationState.Opened) { throw new InvalidOperationException("Proxy channel is already opened"); } Collection <ServiceEndpoint> endpoints = new Collection <ServiceEndpoint>(); endpoints.Add(Endpoint); SecurityBehavior.ConfigureAnonymous(endpoints); break; } default: { throw new InvalidOperationException(mode + " is unsupported with this constructor"); } } }