public X509Certificate2 EndGetClientCertificate(IAsyncResult asyncResult)
        {
            if (Logging.On)
            {
                Logging.Enter(Logging.HttpListener, this, "EndGetClientCertificate", "");
            }
            X509Certificate2 objectValue = null;

            try
            {
                if (asyncResult == null)
                {
                    throw new ArgumentNullException("asyncResult");
                }
                ListenerClientCertAsyncResult result = asyncResult as ListenerClientCertAsyncResult;
                if ((result == null) || (result.AsyncObject != this))
                {
                    throw new ArgumentException(SR.GetString("net_io_invalidasyncresult"), "asyncResult");
                }
                if (result.EndCalled)
                {
                    throw new InvalidOperationException(SR.GetString("net_io_invalidendcall", new object[] { "EndGetClientCertificate" }));
                }
                result.EndCalled = true;
                objectValue      = result.InternalWaitForCompletion() as X509Certificate2;
            }
            finally
            {
                if (Logging.On)
                {
                    Logging.Exit(Logging.HttpListener, this, "EndGetClientCertificate", ValidationHelper.HashString(objectValue));
                }
            }
            return(objectValue);
        }
예제 #2
0
        public X509Certificate2 EndGetClientCertificate(IAsyncResult asyncResult)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Enter(this);
            }
            X509Certificate2 clientCertificate = null;

            try
            {
                if (asyncResult == null)
                {
                    throw new ArgumentNullException(nameof(asyncResult));
                }
                ListenerClientCertAsyncResult clientCertAsyncResult = asyncResult as ListenerClientCertAsyncResult;
                if (clientCertAsyncResult == null || clientCertAsyncResult.AsyncObject != this)
                {
                    throw new ArgumentException(SR.net_io_invalidasyncresult, nameof(asyncResult));
                }
                if (clientCertAsyncResult.EndCalled)
                {
                    throw new InvalidOperationException(SR.Format(SR.net_io_invalidendcall, nameof(EndGetClientCertificate)));
                }
                clientCertAsyncResult.EndCalled = true;
                clientCertificate = clientCertAsyncResult.InternalWaitForCompletion() as X509Certificate2;
                if (NetEventSource.IsEnabled)
                {
                    NetEventSource.Info(this, $"_clientCertificate:{_clientCertificate}");
                }
            }
            finally
            {
                if (NetEventSource.IsEnabled)
                {
                    NetEventSource.Exit(this);
                }
            }
            return(clientCertificate);
        }