Skip to main content

Crate turnloop_tls

Crate turnloop_tls 

Source
Expand description

TLS record processing with caller-owned encrypted buffers and caller-supplied time.

Handle every returned rustls state before calling process again, discard status.discard input bytes only after handling it, and acknowledge TransmitTlsData only after the host has completed all writes. Plaintext records borrow rustls storage; consume them before advancing the state.

§Configuration

ClientConfig::new and ServerConfig::new cover static TLS: roots or a certificate chain, a key and ALPN. A host that needs a rustls decision those constructors do not expose (client certificates, SNI resolvers, custom verifiers, ticketers, protocol versions) builds the rustls config itself and wraps it with ClientConfig::from_rustls / ServerConfig::from_rustls, passing HostTime::time_provider to builder_with_details so certificate validity keeps following the time handed to process.

§Crypto provider

The default ring feature makes ring the provider new uses when the host names none. ClientOptions::provider and ServerConfig::with_provider select any other rustls CryptoProvider, such as aws-lc-rs. With default-features = false this crate links no provider of its own: new then uses the one the host passes, or the process-default provider installed with rustls, and fails if there is neither. Without ring, tls_server_end_point is unavailable; hash the certificate with the algorithm tls_server_end_point_hash selects instead.

§Getting started on turnloop

Enable the turnloop feature for the asynchronous module. The embedding host owns LocalExecutor and calls turn; adapters await its streams and deadline futures. See the crate README and turnloop-io for ownership, streaming and cancellation examples. Default features retain the sans-I/O API.

Re-exports§

pub use rustls;

Structs§

Client
ClientConfig
ClientOptions
Node’s explicit ca replaces default roots. Extra CA PEM augments Mozilla roots only when explicit CA is absent. The host reads NODE_EXTRA_CA_CERTS once at startup and supplies its contents; this crate never reads files/env.
HostTime
A shared wall clock that only the host advances.
Server
ServerConfig
UnbufferedStatus
The current status of the UnbufferedConnection*

Enums§

ConnectionState
The state of the UnbufferedConnectionCommon object
EndPointHash
The hash RFC 5929 §4.1 selects for a certificate’s tls-server-end-point.

Functions§

node_error_code
Stable Node-style cause code. Rustls cannot distinguish a missing intermediate from an untrusted root; both map to UNABLE_TO_VERIFY_LEAF_SIGNATURE.
tls_server_end_point
Hash a verified server leaf’s DER for RFC 5929 §4.1 tls-server-end-point. RSA/ECDSA SHA-256/384/512 and RSA-PSS parameters are supported. MD5/SHA-1 signatures use SHA-256. Unknown algorithms (including Ed25519), malformed DER and undefined bindings return None. This helper does not verify certificates and performs no allocation; call it after successful TLS authentication.
tls_server_end_point_hash
The hash tls_server_end_point would apply to this leaf’s DER, for hosts that hash with their own crypto provider. None in exactly the same cases.