Exemple #1
0
        public Task AuthenticateAsClientAsync(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
        {
            var options = new MonoSslClientAuthenticationOptions {
                TargetHost                     = targetHost,
                ClientCertificates             = clientCertificates,
                EnabledSslProtocols            = enabledSslProtocols,
                CertificateRevocationCheckMode = checkCertificateRevocation ? X509RevocationMode.Online : X509RevocationMode.NoCheck,
                EncryptionPolicy               = EncryptionPolicy.RequireEncryption
            };

            return(ProcessAuthentication(false, options, CancellationToken.None));
        }
Exemple #2
0
        public IAsyncResult BeginAuthenticateAsClient(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
        {
            var options = new MonoSslClientAuthenticationOptions {
                TargetHost                     = targetHost,
                ClientCertificates             = clientCertificates,
                EnabledSslProtocols            = enabledSslProtocols,
                CertificateRevocationCheckMode = checkCertificateRevocation ? X509RevocationMode.Online : X509RevocationMode.NoCheck,
                EncryptionPolicy               = EncryptionPolicy.RequireEncryption
            };

            var task = ProcessAuthentication(false, options, CancellationToken.None);

            return(TaskToApm.Begin(task, asyncCallback, asyncState));
        }
        public void AuthenticateAsClient(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
        {
            var options = new MonoSslClientAuthenticationOptions {
                TargetHost                     = targetHost,
                ClientCertificates             = clientCertificates,
                EnabledSslProtocols            = enabledSslProtocols,
                CertificateRevocationCheckMode = checkCertificateRevocation ? X509RevocationMode.Online : X509RevocationMode.NoCheck,
                EncryptionPolicy               = EncryptionPolicy.RequireEncryption
            };

            var task = ProcessAuthentication(true, options, CancellationToken.None);

            try {
                task.Wait();
            } catch (Exception ex) {
                throw HttpWebRequest.FlattenException(ex);
            }
        }