Exemple #1
0
 internal static Task AuthenticateAsClientAsync(this System.Net.Security.SslStream source,
     string targetHost)
 {
     return Task.Factory.FromAsync(
         (c, s) => source.BeginAuthenticateAsClient(targetHost, c, s),
         (r) => source.EndAuthenticateAsClient(r),
         null);
 }
Exemple #2
0
 internal static Task AuthenticateAsClientAsync(this System.Net.Security.SslStream source,
     string targetHost,
     System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates,
     System.Security.Authentication.SslProtocols enabledSslProtocols,
     bool checkCertificateRevocation)
 {
     return Task.Factory.FromAsync(
         (c, s) => source.BeginAuthenticateAsClient(targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, c, s),
         (r) => source.EndAuthenticateAsClient(r),
         null);
 }
        /// <summary>
        /// Extends BeginAuthenticateAsClient so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// sslstream.BeginAuthenticateAsClient(targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginAuthenticateAsClient(this SslStream sslstream, String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation, AsyncCallback asyncCallback)
        {
            if(sslstream == null) throw new ArgumentNullException("sslstream");

            return sslstream.BeginAuthenticateAsClient(targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, null);
        }
        /// <summary>
        /// Extends BeginAuthenticateAsClient so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// sslstream.BeginAuthenticateAsClient(targetHost, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginAuthenticateAsClient(this SslStream sslstream, String targetHost, AsyncCallback asyncCallback)
        {
            if(sslstream == null) throw new ArgumentNullException("sslstream");

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

            return negotiatestream.BeginAuthenticateAsClient(credential, binding, targetName, requiredProtectionLevel, allowedImpersonationLevel, asyncCallback, null);
        }
        /// <summary>
        /// Extends BeginAuthenticateAsClient so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// negotiatestream.BeginAuthenticateAsClient(credential, targetName, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginAuthenticateAsClient(this NegotiateStream negotiatestream, System.Net.NetworkCredential credential, String targetName, AsyncCallback asyncCallback)
        {
            if(negotiatestream == null) throw new ArgumentNullException("negotiatestream");

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

            return negotiatestream.BeginAuthenticateAsClient(asyncCallback, null);
        }