Exemplo n.º 1
0
        private SslStreamSettings ConfigureSsl(SslStreamSettings settings, ClusterKey clusterKey)
        {
            if (clusterKey.SslSettings != null)
            {
                var validationCallback = clusterKey.SslSettings.ServerCertificateValidationCallback;
                if (validationCallback == null && !clusterKey.VerifySslCertificate)
                {
                    validationCallback = AcceptAnySslCertificate;
                }

                return(settings.With(
                           clientCertificates: Optional.Create(clusterKey.SslSettings.ClientCertificates ?? Enumerable.Empty <X509Certificate>()),
                           checkCertificateRevocation: clusterKey.SslSettings.CheckCertificateRevocation,
                           clientCertificateSelectionCallback: clusterKey.SslSettings.ClientCertificateSelectionCallback,
                           enabledProtocols: clusterKey.SslSettings.EnabledSslProtocols,
                           serverCertificateValidationCallback: validationCallback));
            }

            return(settings);
        }
        private SslStreamSettings ConfigureSsl(SslStreamSettings settings, ClusterKey clusterKey)
        {
            if (clusterKey.UseTls)
            {
                var sslSettings = clusterKey.SslSettings ?? new SslSettings();

                var validationCallback = sslSettings.ServerCertificateValidationCallback;
                if (validationCallback == null && clusterKey.AllowInsecureTls)
                {
                    validationCallback = AcceptAnySslCertificate;
                }

                return(settings.With(
                           clientCertificates: Optional.Enumerable(sslSettings.ClientCertificates ?? Enumerable.Empty <X509Certificate>()),
                           checkCertificateRevocation: sslSettings.CheckCertificateRevocation,
                           clientCertificateSelectionCallback: sslSettings.ClientCertificateSelectionCallback,
                           enabledProtocols: sslSettings.EnabledSslProtocols,
                           serverCertificateValidationCallback: validationCallback));
            }

            return(settings);
        }