示例#1
0
        private DigitalSignatureServicePortTypeClient CreateDSSPClient()
        {
            DigitalSignatureServicePortTypeClient client;

            if (string.IsNullOrEmpty(this.Application.UT.Password) &&
                this.Application.X509.Certificate == null &&
                this.Application.X509.FindValue == null)
            {
                client = new DigitalSignatureServicePortTypeClient(new PlainDsspBinding(), Address);
            }
            else if (this.Application.X509.Certificate != null)
            {
                client = new DigitalSignatureServicePortTypeClient(new X509DsspBinding(), Address);
                client.ClientCredentials.ClientCertificate.Certificate = this.Application.X509.Certificate;
            }
            else if (this.Application.X509.FindValue != null)
            {
                client = new DigitalSignatureServicePortTypeClient(new X509DsspBinding(), Address);
                client.ClientCredentials.ClientCertificate.SetCertificate(this.Application.X509.StoreLocation,
                                                                          this.Application.X509.StoreName, this.Application.X509.FindType, this.Application.X509.FindValue);
            }
            else
            {
                client = new DigitalSignatureServicePortTypeClient(new UTDsspBinding(), Address);
                client.ClientCredentials.UserName.UserName = this.Application.UT.Name;
                client.ClientCredentials.UserName.Password = this.Application.UT.Password;
            }
            return(client);
        }
示例#2
0
        private DigitalSignatureServicePortTypeClient CreateDSSPClient(DsspSession session)
        {
            var client = new DigitalSignatureServicePortTypeClient(new ScDsspBinding(), Address);

            client.ChannelFactory.Endpoint.Behaviors.Remove <ClientCredentials>();
            client.ChannelFactory.Endpoint.Behaviors.Add(new ScDsspClientCredentials(session.KeyId, session.KeyValue));
            return(client);
        }
        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
                {
                    Console.WriteLine("Accept ANY SSL Certificate");
                    ServicePointManager.ServerCertificateValidationCallback =
                        new RemoteCertificateValidationCallback(WCFUtil.AnyCertificateValidationCallback);
                }
            }

            if (null == this.client)
            {
                // Setup basic client
                Binding binding;
                if (sslLocation)
                {
                    binding = WCFUtil.BasicHttpOverSSLBinding(this.maxReceivedMessageSize);
                }
                else
                {
                    binding = new BasicHttpBinding();
                    if (this.maxReceivedMessageSize > 0)
                    {
                        ((BasicHttpBinding)binding).MaxReceivedMessageSize = maxReceivedMessageSize;
                    }
                }
                this.client = new DigitalSignatureServicePortTypeClient(binding, remoteAddress);

                // Add logging behaviour
                if (this.logging)
                {
                    this.client.Endpoint.Behaviors.Add(new LoggingBehavior());
                }
            }
        }
        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
                {
                    Console.WriteLine("Accept ANY SSL Certificate");
                    ServicePointManager.ServerCertificateValidationCallback =
                        new RemoteCertificateValidationCallback(WCFUtil.AnyCertificateValidationCallback);
                }
            }

            if (null == this.client)
            {
                // Setup basic client
                Binding binding;
                if (sslLocation)
                {
                    binding = WCFUtil.BasicHttpOverSSLBinding(this.maxReceivedMessageSize);
                }
                else
                {
                    binding = new BasicHttpBinding();
                    if (this.maxReceivedMessageSize > 0) ((BasicHttpBinding)binding).MaxReceivedMessageSize = maxReceivedMessageSize;
                }
                this.client = new DigitalSignatureServicePortTypeClient(binding, remoteAddress);

                // Add logging behaviour
                if (this.logging)
                {
                    this.client.Endpoint.Behaviors.Add(new LoggingBehavior());
                }
            }
        }