Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

TlsStream Class

Namespace: Rebex.Net
Assembly: Rebex.Tls.dll (version 7.0.9119)

Represents a TLS-enabled TCP stream.

Syntax
public class TlsStream : Stream, IAsyncDisposable, IDisposable
Inheritance
Object
MarshalByRefObject
Stream
TlsStream
Implements
IAsyncDisposable
IDisposable
Inherited Members
Stream.Close()
Stream.CopyTo(Stream)
Stream.CopyTo(Stream, Int32)
Stream.CopyToAsync(Stream)
Stream.CopyToAsync(Stream, Int32)
Stream.CopyToAsync(Stream, Int32, CancellationToken)
Stream.CopyToAsync(Stream, CancellationToken)
Stream.CreateWaitHandle()
Stream.Dispose()
Stream.FlushAsync()
Stream.Null
Stream.ObjectInvariant()
Stream.Read(Span<Byte>)
Stream.ReadAsync(Byte[], Int32, Int32)
Stream.ReadAsync(Memory<Byte>, CancellationToken)
Stream.ReadAtLeast(Span<Byte>, Int32, Boolean)
Stream.ReadAtLeastAsync(Memory<Byte>, Int32, Boolean, CancellationToken)
Stream.ReadByte()
Stream.ReadExactly(Byte[], Int32, Int32)
Stream.ReadExactly(Span<Byte>)
Stream.ReadExactlyAsync(Byte[], Int32, Int32, CancellationToken)
Stream.ReadExactlyAsync(Memory<Byte>, CancellationToken)
Stream.Synchronized(Stream)
Stream.ValidateBufferArguments(Byte[], Int32, Int32)
Stream.ValidateCopyToArguments(Stream, Int32)
Stream.Write(ReadOnlySpan<Byte>)
Stream.WriteAsync(Byte[], Int32, Int32)
Stream.WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)
Stream.WriteByte(Byte)
MarshalByRefObject.GetLifetimeService()
MarshalByRefObject.InitializeLifetimeService()
MarshalByRefObject.MemberwiseClone(Boolean)
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)

Remarks

This class is suitable for securing your socket communication using TLS 1.3, TLS 1.2, TLS 1.1 and TLS 1.0 protocols.

Constructors

Name Description
TlsStream(Stream)

Initializes the TlsStream instance. The TlsStream becomes the owner of the supplied stream.

TlsStream(Socket)

Initializes the TlsStream instance. The TlsStream becomes the owner of the supplied socket.

Properties

Name Description
ApplicationProtocol

Gets the negotiated application protocol (via ALPN extension).

CanRead

Gets a value indicating whether the stream is readable.

CanSeek

Returns false. (TLS stream is not seekable.)

CanTimeout

Gets a value indicating whether the stream can time out.

CanWrite

Gets a value indicating whether the stream is writable.

Cipher

Gets the negotiated TLS cipher.

IsAuthenticated

Gets a value indicating whether TLS security on this TlsStream was successfully negotiated.

IsServer

Gets a value indicating whether the local side of the TLS connection is the server side.

Length

Not supported. Throws NotSupportedException.

LocalCertificate

Gets the certificate chain used to authenticate the remote endpoint.

LogWriter

Gets or sets the log writer used by this object.

Parameters

Gets or sets the security parameters of the current TlsStream.

Position

Not supported. Throws NotSupportedException.

ReadTimeout

Gets or sets the length of time, in milliseconds, until the read operation times out, or the value -1 or 0 to indicate that the operation does not time out.

RemoteCertificate

Gets the certificate chain used to authenticate the remote endpoint.

WriteTimeout

Gets or sets the length of time, in milliseconds, until the write operation times out, or the value -1 or 0 to indicate that the operation does not time out.

Methods

Name Description
AuthenticateAsClient(TlsClientSettings)

Performs TLS negotiation. This TlsStream will behave as a TLS client. To configure security parameters not available in settings use the Parameters property.

AuthenticateAsClient(String)

Performs TLS negotiation. This TlsStream will behave as a TLS client. To configure security parameters use the Parameters property.

AuthenticateAsClientAsync(TlsClientSettings)

Performs TLS negotiation. This TlsStream will behave as a TLS client. To configure security parameters use the Parameters property.

AuthenticateAsClientAsync(TlsClientSettings, CancellationToken)

Performs TLS negotiation. This TlsStream will behave as a TLS client. To configure security parameters use the Parameters property.

AuthenticateAsClientAsync(String)

Performs TLS negotiation. This TlsStream will behave as a TLS client. To configure security parameters use the Parameters property.

AuthenticateAsServer(TlsServerSettings)

Performs TLS negotiation. This TlsStream will behave as a TLS server. To configure security parameters use the Parameters property.

AuthenticateAsServer(CertificateChain)

Performs TLS negotiation. This TlsStream will behave as a TLS server. To configure security parameters use the Parameters property.

AuthenticateAsServerAsync(TlsServerSettings)

Performs TLS negotiation. This TlsStream will behave as a TLS server. To configure security parameters use the Parameters property.

AuthenticateAsServerAsync(TlsServerSettings, CancellationToken)

Performs TLS negotiation. This TlsStream will behave as a TLS server. To configure security parameters use the Parameters property.

AuthenticateAsServerAsync(CertificateChain)

Performs TLS negotiation. This TlsStream will behave as a TLS server. To configure security parameters use the Parameters property.

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

Asynchronously reads data from this TlsStream.

BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

Asynchronously writes data into this TlsStream.

CloseAsync()

Asynchronously releases resources used by the TlsStream.

Dispose(Boolean)

Releases resources used by this stream.

DisposeAsync()

Asynchronously releases resources used by this stream.

EndRead(IAsyncResult)

Ends a pending asynchronous read request.

EndWrite(IAsyncResult)

Ends a pending asynchronous write request.

Flush()

Causes any buffered data to be written. Has no effect on TlsStream.

FlushAsync(CancellationToken)

Causes any buffered data to be written. Has no effect on TlsStream.

GetChannelBinding(ChannelBindingType)

Gets an instance of the ChannelBinding that matches the bindingType. When the requested ChannelBinding is not available, then it returns an empty instance of the ChannelBinding.

GetHashCode()

Gets a hash code of this object.

HasChannelBinding(ChannelBindingType)

Gets an indication whether a provider has a ChannelBinding that matches the bindingType. If the method returns true, it means that the next call of the GetChannelBinding(ChannelBindingType) method returns valid (non-empty) instance of the ChannelBinding that matches bindingType.

Read(Byte[], Int32, Int32)

Reads data from this TlsStream.

ReadAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronously reads data from this TlsStream.

Seek(Int64, SeekOrigin)

Not supported. Throws NotSupportedException.

SetLength(Int64)

Not supported. Throws NotSupportedException.

Shutdown()

Disables sends on this TlsStream.

ShutdownAsync()

Disables sends on this TlsStream.

ToString()

Returns a string representation of this object.

Write(Byte[], Int32, Int32)

Writes data into this TlsStream.

WriteAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronously writes data into this TlsStream.

Events

Name Description
ClientHelloReceived

Occurs when a TLS ClientHello has been received (useful for TLS servers only).

ValidatingCertificate

Occurs when a certificate provided by the remote end needs to be validated.

In This Article
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies