API Reference
StreamSec.Snip.TLSServer
Secure Network Interface Framework - StreamSec.Snip.TLSServer
snip (Snif class remoting) as an application-layer plugin for the async TLS
server - the TLS counterpart of StreamSec.Snip.SSHServer.
DELIBERATELY NOT A COMPLETE SERVER, unlike the SSH-based TsnipServer. It owns
no listener, no socket, no host key and no transport policy: it is one
iAppProtocol that an application registers with a TsmAsyncTLSServer, exactly
the way TsmHTTPSv2 is registered:
TsnifClassServer.RegisterServerClass(TMyRemotedThing); // process-wide
snip := TsnipTLSServer.Create(Self); // owns a class server
tls := TsmAsyncTLSServer.Create(Self);
tls.OnConfigureEngine := ConfigureEngine; // identity, trust, options
tls.Protocols.AddProtocol(snip.AppProtocol);
tls.BindPort := 4443;
tls.Active := True;
Everything about the TLS side - certificates, client authentication, ALPN
fallback policy, admission limits, sharding - therefore belongs to the async
TLS server component and its OnConfigureEngine handler, not here.
THREADING. The async server is a reactor: it hands each session decrypted
plaintext on an I/O thread and that call must return promptly. The Snif class
server, by contrast, is a blocking read-request/process/write-response loop
that may call back INTO the client mid-request. So each session runs that loop
on a thread of its own: the reactor thread only appends bytes to the session's
connection buffer (AddIn) and wakes the serving thread.
CHANNEL BINDING. The per-session connection is a TsnipServerTLSOctetConnection,
which exposes IsnifChannelBinding backed by the RFC 9266 tls-exporter value of
THIS TLS connection (via iAppTransport.ExportKeyingMaterial). That is what the
Snif KAPA folds into its transcript, so an authentication cannot be
relayed onto another TLS channel. It needs a completed TLS 1.3 handshake;
authentication fails closed without one.
Feature notes: Snif remoting framework (concepts)
Classes, interfaces and records
inherits from TComponent
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function AppProtocol: iAppProtocol;
Register this with TsmAsyncTLSServer.Protocols.AddProtocol. The same instance is returned every time, so registering with several servers shares this component's one ClassServer - which is normally what you want.
Full description »
procedure Start; virtual;
Stops/starts accepting new snip work. Stop also winds down the serving loops of connections that are already up (each notices at its next poll) and then WAITS for those threads to finish, up to DrainTimeout, so nothing is still dispatching when it returns. Call it from the application's own thread - never from a TLS callback.
» member page
procedure Stop; virtual;
property DrainTimeout: Cardinal read fDrainTimeout write fDrainTimeout;
Milliseconds Stop/Destroy wait for live serving threads to finish (default 10000). Whatever is still running when it expires is left to unwind on its own, so a hung application request handler cannot wedge shutdown. An idle connection now costs about one poll interval rather than all of this: the serving loop re-reads Active every slice.
» member page
property ServerName: string read fServerName write fServerName;
Informational name for the served endpoint; carried for parity with TsnipSSHServer, not used on the wire.
» member page
property ClassServer: TsnifClassServer read fClassServer;
THE SNIF CLASS SERVER THAT DISPATCHES REMOTED CALLS - owned by this component, created with it, freed with it, and never nil.
Full description »
class function CurrentTransportInfo: iTLSConnectionInfo;
WHO IS CALLING, FOR A SNIF METHOD RUNNING ON A SNIP-OVER-TLS CONNECTION. A remoted method never sees the connection it arrived on; these two read it from TsnifClassServer.CurrentContext, which belongs to the calling thread for the duration of one call.
Full description »
class function CurrentPeerCertificate: iCertificate;
property MaxFrameSize: Integer read fMaxFrameSize write SetMaxFrameSize default cSnipDefaultMaxFrameSize;
Maximum inbound frame BODY in octets (at least 1; default 16 MiB). TLS/QUIC also use it for the AddIn buffered-plaintext ceiling. A message is one frame: size this for the largest legitimate message, including padding. A peer can make this end buffer about one frame per connection. Changes apply only to connections created afterwards, never to live framers.
» member page
property PadRequestsTo: Integer read fPadRequestsTo write fPadRequestsTo default 0;
FRAME PADDING, passed to every connection this server accepts - see TsnipBaseOctetConnection. Zero, the default, changes nothing.
A server pads what it SENDS, which is responses, and may require what it RECEIVES, which is requests; both numbers are set here and which applies follows from the kind. Set the same pair on the client.
» member page
property PadResponsesTo: Integer read fPadResponsesTo write fPadResponsesTo default 0;
property RequirePadding: Boolean read fRequirePadding write fRequirePadding default False;
Refuses an inbound frame that is not padded to PadRequestsTo. Leave it off until every client pads, then turn it on: an adversary who can make a client fall back to an unpadded connection has undone the padding, and without this nothing notices.
» member page
property Server: TsmAsyncTLSServer read fServer write SetServer;
The async TLS server this plugin is served by. Assigning it registers this plugin with that server's protocol registry (clearing it unregisters), so an application declares the association in the Object Inspector instead of calling Protocols.AddProtocol from code.
Full description »
property AlpnToken: string read fAlpnToken write SetAlpnToken;
The ALPN protocol identifier advertised and matched for snip (default 'snip'). Change it only in step with the client's SnipAlpnToken; a mismatch means the async server never routes the connection here.
Full description »
property AlpnPriority: Integer read fAlpnPriority write SetAlpnPriority default cAlpnPriorityDefault;
Where snip sits in the server's ALPN preference list. HIGHER IS PREFERRED, and the SERVER's order decides - the client's ordering is ignored beyond membership (RFC 7301 sec.3.2; TCustomTLS_ContentLayer.PickProtocol walks our list outermost).
Full description »
property ConnectTimeout: Cardinal read fConnectTimeout write fConnectTimeout default cSnipConnectTimeoutMSec;
Milliseconds an accepted connection has to send its snip connect frame once the TLS handshake is done (default 15000; 0 waits for ever).
Full description »
property ReadTimeout: Cardinal read fReadTimeout write fReadTimeout default cSnipNoTimeout;
Milliseconds the serving loop waits for the next request from a connection that is already up (default 0 = wait for ever).
Full description »
property Active: Boolean read fActive write SetActive default True;
True (the default) while the plugin accepts snip sessions - see Start/Stop.
» member page