private void Init(Stream source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } _current = new RedirectableStream(_source = source); _variableReader = new VariableStreamReader(_current); State = SecurableConnectionState.Open; }
public async Task NegotiateTlsAsync() { if (State != SecurableConnectionState.Open) { throw new InvalidOperationException(); } _current.ChangeSteam( _encrypted = new SslStream( _source, true, RemoteValidationCallback, LocalCertSelectionCallback, EncryptionPolicy.RequireEncryption)); await _encrypted.AuthenticateAsServerAsync(GetCertificate(), false, SslProtocols.Tls12, false); State = SecurableConnectionState.Secured; }