コード例 #1
0
        public Task AuthenticateAsServerAsync(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
            };

            return(ProcessAuthentication(false, options, CancellationToken.None));
        }
コード例 #2
0
        public IAsyncResult BeginAuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
        {
            var options = new MonoSslServerAuthenticationOptions {
                ServerCertificate              = serverCertificate,
                ClientCertificateRequired      = clientCertificateRequired,
                EnabledSslProtocols            = enabledSslProtocols,
                CertificateRevocationCheckMode = checkCertificateRevocation ? X509RevocationMode.Online : X509RevocationMode.NoCheck,
                EncryptionPolicy = EncryptionPolicy.RequireEncryption
            };

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

            return(TaskToApm.Begin(task, asyncCallback, asyncState));
        }
コード例 #3
0
        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);

            task.Wait();
        }
コード例 #4
0
        MNS.MonoSslServerAuthenticationOptions CreateAuthenticationOptions(SslServerAuthenticationOptions sslServerAuthenticationOptions)
        {
            if (sslServerAuthenticationOptions.ServerCertificate == null && sslServerAuthenticationOptions.ServerCertificateSelectionCallback == null && selectionCallback == null)
            {
                throw new ArgumentNullException(nameof(sslServerAuthenticationOptions.ServerCertificate));
            }

            if ((sslServerAuthenticationOptions.ServerCertificate != null || selectionCallback != null) && sslServerAuthenticationOptions.ServerCertificateSelectionCallback != null)
            {
                throw new InvalidOperationException(SR.Format(SR.net_conflicting_options, nameof(ServerCertificateSelectionCallback)));
            }

            var options = new MNS.MonoSslServerAuthenticationOptions(sslServerAuthenticationOptions);

            var serverSelectionCallback = sslServerAuthenticationOptions.ServerCertificateSelectionCallback;

            if (serverSelectionCallback != null)
            {
                options.ServerCertSelectionDelegate = (x) => serverSelectionCallback(this, x);
            }

            return(options);
        }