public void AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
        {
            var options = new MonoSslServerAuthenticationOptions {
                ServerCertificate              = serverCertificate,
                ClientCertificateRequired      = clientCertificateRequired,
                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);
            }
        }
        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);
            }
        }