예제 #1
0
 internal static Task AuthenticateAsServerAsync(this System.Net.Security.SslStream source,
     System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate)
 {
     return Task.Factory.FromAsync(
         (c, s) => source.BeginAuthenticateAsServer(serverCertificate, c, s),
         (r) => source.EndAuthenticateAsServer(r),
         null);
 }
예제 #2
0
 internal static Task AuthenticateAsServerAsync(this System.Net.Security.SslStream source,
     System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate,
     bool clientCertificateRequired,
     System.Security.Authentication.SslProtocols enabledSslProtocols,
     bool checkCertificateRevocation)
 {
     return Task.Factory.FromAsync(
         (c, s) => source.BeginAuthenticateAsServer(serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, c, s),
         (r) => source.EndAuthenticateAsServer(r),
         null);
 }
        /// <summary>
        /// Extends BeginAuthenticateAsServer so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// sslstream.BeginAuthenticateAsServer(serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginAuthenticateAsServer(this SslStream sslstream, System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, Boolean clientCertificateRequired, System.Security.Authentication.SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation, AsyncCallback asyncCallback)
        {
            if(sslstream == null) throw new ArgumentNullException("sslstream");

            return sslstream.BeginAuthenticateAsServer(serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, null);
        }
        /// <summary>
        /// Extends BeginAuthenticateAsServer so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// sslstream.BeginAuthenticateAsServer(serverCertificate, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginAuthenticateAsServer(this SslStream sslstream, System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, AsyncCallback asyncCallback)
        {
            if(sslstream == null) throw new ArgumentNullException("sslstream");

            return sslstream.BeginAuthenticateAsServer(serverCertificate, asyncCallback, null);
        }
        /// <summary>
        /// Extends BeginAuthenticateAsServer so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// negotiatestream.BeginAuthenticateAsServer(asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginAuthenticateAsServer(this NegotiateStream negotiatestream, AsyncCallback asyncCallback)
        {
            if(negotiatestream == null) throw new ArgumentNullException("negotiatestream");

            return negotiatestream.BeginAuthenticateAsServer(asyncCallback, null);
        }
        /// <summary>
        /// Extends BeginAuthenticateAsServer so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// negotiatestream.BeginAuthenticateAsServer(credential, policy, requiredProtectionLevel, requiredImpersonationLevel, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginAuthenticateAsServer(this NegotiateStream negotiatestream, System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback asyncCallback)
        {
            if(negotiatestream == null) throw new ArgumentNullException("negotiatestream");

            return negotiatestream.BeginAuthenticateAsServer(credential, policy, requiredProtectionLevel, requiredImpersonationLevel, asyncCallback, null);
        }
        /// <summary>
        /// Extends BeginAuthenticateAsServer so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// negotiatestream.BeginAuthenticateAsServer(policy, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginAuthenticateAsServer(this NegotiateStream negotiatestream, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, AsyncCallback asyncCallback)
        {
            if(negotiatestream == null) throw new ArgumentNullException("negotiatestream");

            return negotiatestream.BeginAuthenticateAsServer(policy, asyncCallback, null);
        }