The snip client over TLS - the drop-in counterpart of StreamSec.Snip.Client's TsnipClient, with the SSH transport replaced by a raw stSocket carrying TLS. Same shape as the SSH client: it descends from TsnicClassClient, builds and configures its own transport component in the constructor, publishes that component (with an inert setter, because the client owns it), and Start does the whole bring-up - connect, handshake, open the snip channel, log the Snif user in. TWO TIERS, ONE BODY, the same division of labour StreamSec.Mobile.TLSClient uses. TsnipCustomTLSClient does all the work and acquires its engine through the virtual GetNewTLSServer; TsnipTLSClient overrides that to CREATE AND OWN one (the shape described above, unchanged); TsnipAdvancedTLSClient overrides nothing there, so it takes an EXTERNAL engine through a settable TLSServer and falls back to the process-wide GlobalServer when none is assigned. The advanced tier exists because an engine is expensive and a connection is not: building and tearing one down costs several times what the handshake it serves does, so a process that opens many short-lived snip connections wants ONE engine - one set of trust anchors, one client identity, one suite policy - behind all of them. The transport component here is a TsmSimpleTLSInternalServer. Despite the name it is the configuration/identity holder for BOTH TLS roles; this client uses its client side (TLSAddClientSession). Reach into it for anything the published properties below do not cover: trust anchors (LoadRootCertsFromFile), a client identity for mutual TLS (ImportFromPFX), suite/group/signature policy (Options). TLS 1.3 IS THE POINT, not just a default. The Snif KAPA binds itself to the RFC 9266 tls-exporter value of this connection, and that value only exists after a TLS 1.3 handshake - see StreamSec.Snip.TLSOctetConnection. KAPA login fails closed against a 1.2 peer.
Feature notes: Snif remoting framework (concepts)
inherits from TsnicClassClient
The body of the client, with no opinion about WHERE its TLS engine comes from: it is acquired through the virtual GetNewTLSServer and reached through ActiveTLSServer, the same seam StreamSec.Mobile.TLSClient's TsmCustomTLSClient uses. Abstract in role rather than in Delphi - it carries no platform attribute and is never registered on the palette; the two tiers below are.
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Start;
procedure Stop;
function LoginKAPA(const aSecret: tBytes; out aSessionKey: tBytes): Boolean;
procedure StartTransport;
function RecoverAccount: Boolean;
property MaxFrameSize: Integer read fMaxFrameSize write SetMaxFrameSize default cSnipDefaultMaxFrameSize;
property PadRequestsTo: Integer read fPadRequestsTo write fPadRequestsTo default 0;
property PadResponsesTo: Integer read fPadResponsesTo write fPadResponsesTo default 0;
property RequirePadding: Boolean read fRequirePadding write fRequirePadding default False;
property Host: string read fHost write SetHost;
property Port: Word read fPort write SetPort default cSnipDefaultPort;
property ServerName: string read fServerName write SetServerName;
property AlpnToken: string read fAlpnToken write SetAlpnToken;
property SnifUsername: string read fSnifUsername write SetSnifUsername;
property SnifPassword: string read fSnifPassword write SetSnifPassword;
property OnOTPCode: tSnipOTPCodeEvent read fOnOTPCode write fOnOTPCode;
property OnNewPassword: tSnipNewPasswordEvent read fOnNewPassword write fOnNewPassword;
property RecoveryHeartbeatInterval: Cardinal read fRecoveryHeartbeatInterval write fRecoveryHeartbeatInterval default cSnipRecoveryHeartbeatMSec;
property HandshakeTimeout: Cardinal read fHandshakeTimeout write fHandshakeTimeout default cSnipHandshakeTimeoutMSec;
property ReadTimeout: Cardinal read fReadTimeout write fReadTimeout default cSnipNoTimeout;
property OnConfigureLayer: tSnipTLSLayerEvent read fOnConfigureLayer write fOnConfigureLayer;
property OnTransportReady: tSnipTLSLayerEvent read fOnTransportReady write fOnTransportReady;
inherits from TsnipCustomTLSClient
The self-contained tier: it CREATES AND OWNS the TLS configuration component, so a client dropped on a form works with no other component wired up. Bare name rather than an adjective, matching the client families in this library - the adjective marks the tier that takes an external engine.
property TLSServer;
inherits from TsnipCustomTLSClient
The tier that takes an EXTERNAL engine, so several clients share one set of trust anchors, one client identity and one suite policy - and pay for building that once instead of once per connection. Leaving TLSServer nil falls back to the process-wide GlobalServer, which is what makes this work with no wiring at all in an application that already has one.
IT NEVER CHANGES THE ENGINE'S ROLE. The engine is the application's and may be accepting connections at the same time, so its ClientOrServer is the application's business - set it to cosClientSide on an engine used only for connecting out. What this tier does do is bring the engine up for client use once (CheckLoaded + TLSSetupClient, the supported route) rather than poking its internals on every connect; see PrepareEngine for why that is the whole of it.
ONE ENGINE, MANY CLIENTS, CONCURRENTLY: each connection gets its own content layer from TLSAddClientSession, and the engine serializes the session list internally, so two clients sharing an engine may hand-shake on two threads. Attaching a client to the engine, re-pointing it and freeing it are serialized against every other client of that engine as well, so clients may be created, pointed at a shared engine and freed on any thread. What is NOT shared is a client instance: one connection at a time, as with the self-owning tier.
DFM NOTE. This tier and TsnipTLSClient publish the same property name with opposite ownership, so changing an existing form's component from one class to the other does not carry the reference across: the self-owning tier's engine is a named child of the client, and a stored "TLSServer = Client1.TLSServer" line cannot resolve against a class that creates no child. It fails quietly - the reference stays nil and this tier falls back to GlobalServer - so re-assign TLSServer after such a change.
property TLSServer;
Account-recovery interaction events (see RecoverAccount). Fired on RecoverAccount's calling thread; the handler may block for as long as the user needs - a background heartbeat keeps the idle connection alive meanwhile. Set aCancel (or return an empty value) to abandon recovery; RecoverAccount then fails closed.
The two per-connection TLS hooks as EVENTS, so an application can reach them without descending. The argument list matches StreamSec.Mobile.TLSClient's tTLSClientLayerEvent deliberately: Delphi matches method-pointer types structurally, so ONE handler method can serve a snip client and a protocol client alike - which is what lets an application's resumption-ticket store attach to either. Each is fired by the matching protected virtual AFTER that virtual has done its own work, so a descendant that overrides the virtual and does not call inherited replaces the event along with it.