private void setupClient() { EndpointAddress remoteAddress = new EndpointAddress(this.location); bool sslLocation = this.location.StartsWith("https") ? true : false; if (sslLocation) { if (null != this.sslCertificate) { /* * Setup SSL validation */ Console.WriteLine("SSL validation active"); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CertificateValidationCallback); } else { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(WCFUtil.AnyCertificateValidationCallback); } } if (null != this.serverCertificate) { /* * Setup WS-Security */ Console.WriteLine("WS-Security active"); this.client = new XKMSPortTypeClient(new WSSecurityBinding(sslLocation, this.serverCertificate), remoteAddress); // set credentials this.client.ClientCredentials.ServiceCertificate.DefaultCertificate = this.serverCertificate; this.client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; this.client.ClientCredentials.ClientCertificate.Certificate = this.clientCertificate; // set contract this.client.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; } if (null == this.client) { // Setup basic client without WS-Security binding if (sslLocation) { this.client = new XKMSPortTypeClient(WCFUtil.BasicHttpOverSSLBinding(), remoteAddress); } else { this.client = new XKMSPortTypeClient(new BasicHttpBinding(), remoteAddress); } } // add logging behaviour this.client.Endpoint.Behaviors.Add(new LoggingBehavior()); }