protected override async Task <(Stream, SecurityMessageProperty)> OnAcceptUpgradeAsync(Stream stream)
        {
            var sslStream = new SslStream(stream, false, ValidateRemoteCertificate);

            try
            {
                await sslStream.AuthenticateAsServerAsync(_parent.ServerCertificate, _parent.RequireClientCertificate,
                                                          _parent.SslProtocols, false);
            }
            catch (AuthenticationException exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(exception.Message,
                                                                                                           exception));
            }
            catch (IOException ioException)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(
                                                                              SR.Format(SR.NegotiationFailedIO, ioException.Message), ioException));
            }

            SecurityMessageProperty remoteSecurity = _clientSecurity;

            if (IsChannelBindingSupportEnabled)
            {
                _channelBindingToken = ChannelBindingUtility.GetToken(sslStream);
            }

            return(sslStream, remoteSecurity);
        }
Esempio n. 2
0
        protected override void OnClosed()
        {
            base.OnClosed();

            // clean up the CBT after transitioning to the closed state
            ChannelBindingUtility.Dispose(ref _channelBindingToken);
        }
Esempio n. 3
0
        protected override async Task OnCloseAsync(CancellationToken token)
        {
            TimeoutHelper timeoutHelper = new TimeoutHelper(TimeoutHelper.GetOriginalTimeout(token));
            // send back EOF and then recycle the connection
            await Connection.WriteAsync(SingletonEncoder.EndBytes, 0, SingletonEncoder.EndBytes.Length, true, timeoutHelper.RemainingTime());

            connectionDemuxer.ReuseConnection(rawConnection, timeoutHelper.RemainingTime());

            ChannelBindingUtility.Dispose(ref channelBindingToken);
        }
Esempio n. 4
0
 protected void ApplyChannelBinding(Message message)
 {
     ChannelBindingUtility.TryAddToMessage(_channelBindingToken, message, false);
 }