ddn.net.tls.stream

Native TLS stream implementation.

Provides the encrypted stream for reading and writing application data over a TLS connection. Supports non-blocking I/O via TlsProgress return values. Manages handshake state, negotiated parameters, and the underlying transport.

Types 2

Shutdown state machine phases.

NOT_STARTED
SEND_CLOSE_NOTIFY
WAIT_CLOSE_NOTIFY
DONE

Native TLS stream using pure D cryptographic primitives.

Wraps a TlsTransport and provides TLS encryption/decryption. All potentially-blocking operations return TlsProgress or TlsResult to support non-blocking I/O.

Fields
private TlsTransport transport_
private TlsRole role_
private string serverName_
private TlsHandshakeState handshakeState_
private TlsVersion negotiatedVersion_
private CipherSuiteId cipherSuiteId_
private string cipherSuite_
private string alpnProtocol_
private TlsCertificateChain peerCerts_
private TlsSession session_
private TlsVerifyCallback verifyCallback_
private TlsVerifyMode verifyMode_
private ubyte[] readBuffer_
private size_t readPos_
private ubyte[] applicationReadBuffer_
private size_t applicationReadPos_
private TlsError lastError_
private ShutdownState shutdownState_
private bool receivedCloseNotify_
private RecordLayer handshakeRecordLayer_
private Tls13Client tls13Client_
private Tls12Client tls12Client_
private Tls13Server tls13Server_
private Tls12Server tls12Server_
private bool serverHelloPeeked_
private bool serverUseTls13_
TlsVersion minVersion_
TlsVersion maxVersion_
string[] cipherSuites_
string[] alpnProtocols_
ubyte[][] serverCertChainDer_
string serverCertChainPem_
string serverPrivateKeyPem_
TlsSessionCache sessionCache_
TlsAead writeAead_
TlsAead readAead_
Methods
TlsProgress handshake()Performs or continues the TLS handshake.
TlsResult read(ubyte[] buffer)Reads decrypted application data.
TlsResult write(const(ubyte)[] data)Writes application data (will be encrypted).
TlsProgress flush()Flushes any buffered data through the TLS layer.
TlsProgress shutdown()Initiates graceful TLS shutdown (sends close_notify).
TlsError lastError() @property const
void close()
bool isOpen() @property const
bool isHandshakeComplete() @property const
bool receivedCloseNotify() @property const
TlsVersion negotiatedVersion() @property const
string cipherSuite() @property const
string alpnProtocol() @property const
TlsRole role() @property const
string serverName() @property const
TlsSession session() @property const
private void initHandshakeEngine()
private void finalizeHandshake()
private bool detectTls13ClientHello(const(ubyte)[] fragment) static
private void applyEngineResult(CipherSuiteId cs, string alpn, TlsCertificateChain peerCerts, TlsSession tlsSession)
private TlsResult readEncrypted(ubyte[] buffer)
private void processPostHandshakeMessage(const(ubyte)[] plaintext)Handles a decrypted post-handshake message (RFC 8446 §4.6).
private TlsResult writeEncrypted(const(ubyte)[] data)
Constructors
this(TlsTransport transport, TlsRole role, string serverName, TlsVersion minVersion, TlsVersion maxVersion, TlsVerifyMode verifyMode, TlsVerifyCallback verifyCallback)Constructs a NativeTlsStream.