Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mobile.TlsInternalServer

Feature notes: TLS implementation notes (RFC map)

Classes, interfaces and records

classTsmCustomTLSInternalServer

(no public members)

interfaceITLSSocket

function GetTLSServer: TsmCustomTLSInternalServer; procedure SetSocketID(const Value: Pointer); procedure SetTLSServer(const Value: TsmCustomTLSInternalServer); property TLSServer: TsmCustomTLSInternalServer read GetTLSServer write SetTLSServer;

classTAbstractTLSSocket

(no public members)

interfaceISocketRefCounter

procedure Reset;

classTKeepAlive

inherits from TInterfacedObject

implements ISocketRefCounter

constructor Create(ASocket: TAbstractTLSSocket); destructor Destroy; override; procedure Reset;

classTRefCounter

inherits from TInterfacedObject

implements ISocketRefCounter

constructor Create(ASocket: TAbstractTLSSocket); destructor Destroy; override; procedure Reset;

classTAbstractTLSSocket

inherits from TObject

implements ITLSSocket

constructor Create; destructor Destroy; override; procedure Lock; procedure Unlock; procedure Open; procedure Close; function ReceiveLength: Integer; function ReceiveBuf(var Buf; Count: Integer): Integer; function EarlyDataPending: Boolean;
EARLY DATA (NEW): pull-API surface for TLS 1.3 0-RTT, so socket consumers (which read plaintext from ReceiveBuf and never see TsmStreamSecII events) can tell replayable early data apart from ordinary 1-RTT data and find the boundary. Full description »
property EarlyDataStatus: TTLSEarlyDataStatus read FEarlyDataStatus; procedure ReceiveStream(AStream: TStream; AByteCount: Integer = -1; const AReadUntilDisconnect: Boolean = False); procedure SendBuf(const Buf; Count: Integer; SendNow: Boolean = True); procedure SendStream(AStream: TStream; const AAll: Boolean = True; const ASize: Integer = 0; SendNow: Boolean = True); procedure CopySession(ASource: TAbstractTLSSocket); procedure Release; function GetClientCert: iCertificate; function GetClientCertDNSName: string; function GetClientCertIP: string; function GetClientCertURI: string; function GetServerCert: iCertificate;
CLIENT: the session's ServerCertificate. Read GetServerCertAccepted for the acceptance verdict. nil when no session is held - also after a failed connect, because the socket drops its session when the handshake fails; read a refused certificate in OnTLSOutgoingAlert (Client.ServerCertificate) ins... Full description »
function GetServerCertAccepted: Boolean;
CLIENT: the session's ServerCertificateAccepted; False when there is no session. This does not establish that the whole handshake succeeded.
function GetServerCertDNSName: string; function GetServerCertIP: string; function GetServerCertURI: string; property URIToCheck: string read FURIToCheck write SetURIToCheck; property IPToCheck: string read FIPToCheck write SetIPToCheck; property DNSNameToCheck: string read FDNSNameToCheck write SetDNSNameToCheck; property Entity: TConnectionEnd read FEntity; property ErrorCode: Integer read FErrorCode; property Connected: Boolean read FConnected; property ConnectTimeOut: Cardinal read FConnectTimeOut write SetConnectTimeOut; property SleepInterval: Cardinal read FSleepInterval write FSleepInterval; property ResumptionTicket: TTls13ClientTicket read FResumptionTicket write SetResumptionTicket;
TLS 1.3 (NEW): session-ticket resumption. Assign a ticket (ownership passes to the socket, replacing and freeing any previous one) BEFORE the client-side Connect and it is offered as a pre_shared_key in the next handshake. Tickets are single-use: the socket frees the ticket once the handshake has completed (successfully or not).
property OnNewSessionTicket: TTls13NewTicketEvent read FOnNewSessionTicket write FOnNewSessionTicket;
TLS 1.3 (NEW): fired on a CLIENT socket for each NewSessionTicket the server issues after the handshake. The Ticket is owned by the content layer and freed when the handler returns - Clone it and keep the copy to offer through ResumptionTicket on a later connection.

classETLSAlert

inherits from Exception

constructor CreateAlert(AAlertCode: Integer; AFatal: Boolean); property AlertCode: Integer read FAlertCode write SetAlertCode; property Fatal: Boolean read FFatal write SetFatal;

classEIncomingTLSAlert

inherits from ETLSAlert

(no public members)

classEOutgoingTLSAlert

inherits from ETLSAlert

(no public members)

classETLSInternalServer

inherits from ETLSEngineError

Raised by the internal server component for a configuration or key-store problem, as opposed to a protocol alert (ETLSAlert). Part of the TLS engine exception hierarchy - see ETLSEngineError in StreamSec.Mobile.Tls.

(no public members)

interfaceITLSInternalServer

procedure DoNewSocket(Socket: ITLSSocket); procedure DoRemoveSocket(Socket: ITLSSocket);

interfaceiAcmeAlpnTLS

iAcmeAlpnTLS is everything an ACME client needs from a TLS server in order to answer an RFC 8737 tls-alpn-01 challenge and then install the issued identity. It exists so TsmAcmeClient can drive EITHER a single TsmCustomTLSInternalServer or a TsmAsyncTLSServer (which owns N engine shards) without knowing which.

THE FAN-OUT CONTRACT. A multi-engine implementation MUST apply every one of these to ALL of its engines: the CA's validation connection is round-robined onto an arbitrary shard, so a challenge installed on one engine would be found only ~1/N of the time, and a renewed certificate installed on one engine would leave the rest serving the expired one.

THE GATE. The challenge slot is keyed by SNI and only one validation may own it at a time, so bracket an obtain with TryBeginAcmeChallenge/EndAcmeChallenge. TryBeginAcmeChallenge is NON-BLOCKING so a caller can poll and stay responsive, and the gate is recursive on the owning thread. A multi-engine implementation owns ONE gate for the whole bank - TryEnter-ing N gates would give partial acquisition with no clean rollback.

function TryBeginAcmeChallenge: Boolean;
Serialisation gate for tls-alpn-01 validation on this server.
procedure EndAcmeChallenge; procedure ProvisionAcmeChallenge(aKey: TComponent; const aIdentifier, aKeyAuthorization: string);
Registers aKey and installs a throwaway self-signed challenge certificate for aIdentifier carrying SHA-256(aKeyAuthorization) in the critical acmeIdentifier extension, so an acme-tls/1 handshake for that name is answered with it instead of a normal MyCerts leaf. Undo with RemoveTLSAcmeALPN once the CA has validated.
procedure RemoveTLSAcmeALPN;
Drops the challenge certificate. Safe to call when none is installed, and called on every failure path - the challenge must not outlive validation.
function AcmeAddCACertificate(const aCert: iCertificate; var aStatus: TCertStatusCode): Boolean;
Adds an issuer CA from the issued chain, so the swap below can export a complete chain.
procedure ReplaceTLSServerCertificate(const aCert: iCertificate; const aPriv: iMPPrivateKey);
Swaps in the newly issued leaf and its key.

classTsmCustomTLSInternalServer

constructor Create(AOwner: TComponent); override;
Creates the component and its internal machinery: the StreamSecII engine, the TTLSOptions block, and the three certificate stores (MyCerts, RootCerts, TrustedCerts), wiring their cert-not-trusted/not-accepted/ policy and CRL/OCSP revocation callbacks back into this component. Full description »
destructor Destroy; override;
Tears down the component: clears IsGlobalServer if this instance was the global one, releases any tracked sockets, and frees the certificate stores, TTLSOptions and internal StreamSecII engine. » member page
class procedure NotifyLock; static;
SERIALISES MUTATION OF A SHARED ENGINE'S FREE-NOTIFICATION LIST. TComponent.FreeNotification is RECIPROCAL and unsynchronised: it adds to the notified component's FFreeNotifies AND to the notifier's, and RemoveFreeNotification / RemoveFreeNotifications (which TComponent.Destroy calls) do the same... Full description »
class procedure NotifyUnlock; static; function AddCertificate(const Cert: iCertificate; ExplicitTrust: Boolean; var Status: TCertStatusCode; AllowExpired: Boolean = False; AllowDuplicateKeyIdentifier: Boolean = False): Integer; override;
Adds Cert to whichever store it actually belongs in: MyCerts if it matches a private key this component holds, RootCerts if it is a CA certificate, or TrustedCerts if ExplicitTrust is set (otherwise it is rejected with crcInvalidKeyUsage). Full description »
function AddCRL(const CRL: iCertificateList; var Status: TCertStatusCode): Integer; override;
Adds CRL to RootCerts (the store that owns revocation data for this component). Rarely called directly by application code outside of certificate/CRL import flows such as ImportFromPFX. » member page
function ListTLSServerCertificates(aList: TStrings): Integer;
Use this method for listing all server certificates when the server is running, i.e. AFTER TLSSetupServer has been called, and when you don't want to close the server just to manage certificates. Full description »
function FindExpiringTLSServerCertificates(aExpirationDate: TDateTime; aList: TStrings): Integer;
Use this method for validation of server certificates when the server is running, i.e. AFTER TLSSetupServer has been called, and when you don't want to close the server just to manage certificates. Full description »
function FindExpiringTLSServerCertificatesEx(aElapsedFraction: Double; aList: TStrings): Integer;
As above, but the cut-off is the FRACTION of each certificate's validity that must have elapsed (aElapsedFraction = 2/3 -> certificates with less than 1/3 left), matching TsmAcmeRenewalManager.RenewalFraction - the natural "which of my live server certificates are due for renewal?" query, e.g. af... Full description »
procedure ReplaceTLSServerCertificate(const aCert: iCertificate; const aPriv: iMPPrivateKey); overload;
Use this method for replacing a server certificate assigned by TLSSetupServer, without having to close the server and reload all keys and certificates from file. Full description »
procedure ReplaceTLSServerCertificate(const aCert: iCertificate; const aPriv: iMPPrivateKey; const aRetired: array of iCertificate); overload;
As above, and every leaf in aRetired is retired (see TsmStreamSecII): no longer served, not served again by TLSSetupServer and no longer counted by ValidatePublicKeyPairs. » member page
property OnWorkerError: tWorkerFatalEvent read GetOnWorkerError write SetOnWorkerError;
Ordinary errors run on the warm-up worker only. Fatal observers run on helper threads with bounded deadlines before mandatory process termination. Sender is this component. » member page
property OnWorkerFatal: tWorkerFatalEvent read GetOnWorkerFatal write SetOnWorkerFatal; function TryBeginAcmeChallenge: Boolean;
Serialization gate for ACME tls-alpn-01 domain-validation on THIS server. The challenge slot (AddTLSAcmeALPN, keyed by SNI) may be owned by only one validation at a time, so several TsmAcmeRenewalManager instances that share this server must not run their obtains concurrently. Full description »
procedure EndAcmeChallenge; procedure ProvisionAcmeChallenge(aKey: TComponent; const aIdentifier, aKeyAuthorization: string);
iAcmeAlpnTLS. Registers aKey in this server's ring and installs the RFC 8737 challenge certificate for aIdentifier - the single entry point an ACME client uses, so it does not need the protected key store. » member page
function AcmeAddCACertificate(const aCert: iCertificate; var aStatus: TCertStatusCode): Boolean;
iAcmeAlpnTLS. Named to avoid colliding with the AddCertificate overload set; files an issuer CA from a freshly issued chain. » member page
procedure AddTLSAcmeALPN(const aPriv: iMPPrivateKey; const aHostName: string; const aAuthorization: tBytes); overload;
Server-side only: registers a throwaway self-signed certificate (with the RFC 8737 acmeIdentifier extension) plus its private key so that a TLS handshake for aHostName offering the acme-tls/1 ALPN protocol is answered with it instead of a normal MyCerts leaf. Full description »
procedure AddTLSAcmeALPN(const aPriv: iMPPrivateKey; const aHostName: string; const aToken: string; const aThumbprint: string); overload;
Server-side only: same tls-alpn-01 challenge helper as the other overload, but computes the key authorization from the ACME token and account-key thumbprint (SHA-256 of token + '.' + thumbprint) for you. » member page
procedure AddTLSApplicationLayerProtocolName(const ALPN: OctetString);
Advertises an additional protocol name for TLS ALPN (RFC 7301) negotiation, e.g. 'h2' or 'http/1.1', added to the ApplicationProtocols list every new TLSAddClientSession/TLSAddServerSession session is created with. Applies to both roles: a client offers the list in ClientHello, a server picks the first entry from its own list that the client also offered. » member page
procedure RemoveTLSApplicationLayerProtocolName(const ALPN: OctetString);
Withdraws a protocol name previously added with AddTLSApplicationLayerProtocolName. » member page
procedure RemoveTLSAcmeALPN;
Server-side only: clears every acme-tls/1 challenge certificate registered via AddTLSAcmeALPN, e.g. once the ACME CA has validated the challenge and normal TLS serving should resume for that host. » member page
procedure CheckLoaded;
Forces Loaded to run immediately instead of waiting for the component streaming system to call it; an application only needs this when it creates/configures the server component fully at runtime (no DFM) and wants TLSSetupServer-dependent state (like the certificate cache) wired up right away. Full description »
procedure ClearCertificates; dynamic;
Wipes MyCerts, RootCerts and the collected/validated peer-certificate cache. Use this to reset a server or client instance's trust material completely, e.g. before reloading a different certificate set at runtime. » member page
procedure ClearExpiredSessionKeys(aConservative: Boolean = True);
Prunes TLS session-resumption key/ticket state that has aged out. An application with a long-lived server or client component can call this periodically (instead of relying solely on internal expiry checks) to bound memory use; aConservative controls how aggressively stale entries are reclaimed. » member page
procedure ExportToPFX(AFileName: string; Password: ISecretKey = nil; ExportCert: iCertificate = nil; FriendlyName: string = ''; ProviderName: string = ''; ExtKeyUsage: ObjectIdentifierString = ''; Compatibility: Boolean = False);
Writes the identity currently held in MyCerts (a chosen leaf, its issuer chain and any CRLs found for them) out as a password-protected PKCS#12/PFX file, e.g. so it can be backed up or imported into another StreamSec component or a system certificate store. Works the same regardless of ClientOrServer since it only touches the certificate/key stores, not any live TLS session. » member page
function FindCRLs(const CACert: iCertificate; var CRLs: IInterfaceList): Integer; override;
Looks up CRLs for CACert across RootCerts, then MyCerts, then TrustedCerts (in that order, stopping at the first store that has any). Application code rarely calls this directly - it backs the revocation checks that both client and server certificate-chain validation perform internally. » member page
function FindRevocation(const Cert: iCertificate; var RC: iRevokedCertificate): Boolean; override;
Looks up a cached revocation record for Cert, again trying RootCerts, MyCerts and TrustedCerts in turn. Like FindCRLs, this is internal machinery for chain validation rather than something application code calls directly. » member page
function FindTLSSession(const SessionID: TSessionID; var Client: TCustomTLS_ContentLayer): Integer; overload;
Looks up a live TLS session/content layer by its TSessionID (the id used by the TLSConnect/TLSAccept/TLSEncodeData/TLSDecodeData overloads that key sessions by SessionID rather than by an application-owned UserData pointer). Returns the session's index, or a negative value if not found. » member page
function FindTLSSession(UserData: Pointer; var Client: TCustomTLS_ContentLayer): Integer; overload;
Looks up a live TLS session/content layer by the UserData pointer the application supplied when the session was created (e.g. via TLSConnect, TLSAccept or TLSAddClientSession/TLSAddServerSession); this is the usual way an application recovers "its" TCustomTLS_ContentLayer for a given socket/connection object. Returns the session's index, or a negative value if not found. » member page
procedure ImportFromPFX(AFileName: TFileName; Password: ISecretKey); overload;
Loads a password-protected PKCS#12/PFX file (own identity: leaf certificate, private key, issuer chain and CRLs) into this component's stores - the counterpart to ExportToPFX and the usual way an application provisions a server's (or a client's, for mTLS) own certificate/key at startup. Full description »
procedure ImportFromPFX(const aContent: TBytes; aPassword: iSecretKey); overload;
Imports an already-read PFX snapshot. Parsing and decryption run before acquiring the setup and certificate-store mutation locks. » member page
function LoadMyCertsFromFile(AFileName: TFileName): Boolean;
Loads a single DER/CER/CRT certificate, or a PKCS#7 (.p7b/.p7c) bundle, into MyCerts - i.e. this component's own identity, as opposed to LoadRootCertsFromFile/LoadTrustedCertsFromFile which populate the trust stores. Typically used to add a server's (or client's, for mTLS) leaf certificate when the matching private key is supplied separately (e.g. via PrivateKeyRing) rather than bundled in a PFX. » member page
function LoadRootCertsFromFile(AFileName: TFileName): Integer;
Loads a single DER/CER/CRT certificate, or a PKCS#7 (.p7b/.p7c) bundle, into RootCerts - the trust anchors used to validate the peer's certificate chain. Full description »
procedure LoadRootCertsFromStream(AStream: TStream);
Same as LoadRootCertsFromFile but reads from an already-open stream (first trying a PKCS#7 bundle, then falling back to a single DER certificate), for when the CA material is embedded as a resource or fetched over the network rather than living in a standalone file. » member page
procedure LoadTrustedCertsFromFile(AFileName: TFileName);
Loads a single DER/CER/CRT certificate, or a PKCS#7 (.p7b/.p7c) bundle, into TrustedCerts - certificates that are trusted directly (pinned) without needing a chain up to a RootCerts anchor. Useful for pinning a specific peer certificate on either the client or the server side. » member page
function TLSAddClientSession: TCustomTLS_ContentLayer;
Client-side: creates a new outgoing TLS session/content layer (a TCustomTLS_ContentLayer configured from Options/PrivateKeyRing/CACerts), ready to have TLSConnect drive its handshake. Full description »
function TLSAddServerSession: TCustomTLS_ContentLayer;
Server-side: creates a new incoming TLS session/content layer, ready to have TLSAccept drive its handshake against an incoming ClientHello. Most applications let TLSAccept/TLSDecodeData create sessions on demand instead of calling this directly. » member page
function TLSClose(const SessionID: TSessionID; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Closes the TLS session identified by SessionID (send_alert close_notify/Close and release the session), for use with the SessionID-keyed overloads of TLSConnect/TLSEncodeData/TLSDecodeData - i.e. protocols that key a connection by TSessionID rather than by an application-owned UserData pointer. Works from either the client or the server side. » member page
function TLSDecodeData(var SessionID: TSessionID; Src, Data, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Feeds one TLS record (Src) through the SessionID-keyed session, writing decrypted application data to Data and any protocol response (e.g. handshake continuation, alerts) to Response. Works from either the client or the server side, whichever role the session was created with. » member page
function TLSEncodeData(const SessionID: TSessionID; Data, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Encrypts Data into one or more TLS records written to Response, for the SessionID-keyed session. Works from either the client or the server side. » member page
function TLSAccept(UserData: Pointer; Src, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Server-side: drives (or continues) the server handshake for the UserData- keyed session, consuming a ClientHello (or later handshake flight) from Src and writing the server's reply to Response. If no session exists yet for UserData, one is created automatically (see TLSAddServerSession). This is the usual entry point for a plain socket-based TLS server loop. » member page
function TLSAccept(UserData: Pointer; Src, EarlyData, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
TLS 1.3 (NEW, task 11): accept with a 0-RTT EarlyData destination stream. Server-side only: same as the two-stream TLSAccept overload, but any 0-RTT early application data the client sent ahead of the handshake finishing is written to EarlyData instead of being mixed into the post-handshake data... Full description »
function TLSClose(UserData: Pointer; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Closes the TLS session identified by the UserData pointer supplied when it was created (e.g. via TLSConnect/TLSAccept), for use with the UserData- keyed session overloads. Works from either the client or the server side. » member page
function TLSConnect(UserData: Pointer; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Client-side: starts the client handshake for the UserData-keyed session, writing the ClientHello to Response; the server's replies go through TLSDecodeData. Full description »
function TLSConnect(const SessionID: TSessionID; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Client-side: same as the UserData-keyed TLSConnect, but for a session already identified by SessionID rather than a UserData pointer. » member page
function TLSConnect(UserData: Pointer; const SessionID: TSessionID; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Client-side: TLSConnect variant that lets an application supply both a UserData pointer and an explicit SessionID for the same session (e.g. when resuming a specific prior session against a socket object). » member page
function TLSConnect(UserData: Pointer; const SessionID: TSessionID; const CipherSuites: TCipherSuites; Response: TStream; ErrorCode: PInteger): Integer; overload;
Client-side: as the other TLSConnect(UserData, SessionID, ...) overload, but additionally restricts/orders the cipher suites offered for this one connection to CipherSuites, overriding Options.CipherSuites for just this handshake. » member page
function TLSConnectAsServer(UserData: Pointer; Response: TStream; ErrorCode: PInteger = nil): Integer;
Server-side: like TLSAccept, but named for the case where the same component/connection plays the server role while still being driven through the "Connect"-style calling convention (no separate Src stream for the first call) - e.g. dual-role sockets that can be either end of a connection. Internally this creates a server session and calls Accept with a nil source. » member page
function TLSDecodeData(UserData: Pointer; Src, Data, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Feeds one TLS record (Src) through the UserData-keyed session, writing decrypted application data to Data and any protocol response to Response. Full description »
function TLSDecodeData(UserData: Pointer; Src, Data, EarlyData, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
TLS 1.3 (NEW, task 11): decode with a 0-RTT EarlyData destination stream. Server-side only: same as the four-stream TLSDecodeData overload, but any 0-RTT early application data is routed to EarlyData separately from ordinary 1-RTT Data, mirroring the EarlyData overload of TLSAccept. » member page
function TLSEncodeData(UserData: Pointer; Data, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Encrypts Data into one or more TLS records written to Response, for the UserData-keyed session. Works from either the client or the server side. » member page
procedure TLSSetupServer;
Server-side: must be called once, after MyCerts/PrivateKeyRing/Options are configured and before the server accepts any connection, to build the internal per-signature-algorithm certificate and private-key cache (and, if Ocsp is assigned, warm up the OCSP staple cache) that TLSAccept/ TLSConnectA... Full description »
procedure TLSSetupClient;
Client-side: copies the current Options into the internal StreamSecII component immediately, rather than waiting for the next TLSConnect to pick them up implicitly. Full description »
function ValidateMyCert(const Cert: iCertificate): Boolean;
Checks whether Cert (typically one about to be added to MyCerts) has a usable matching private key available via PrivateKeyRing, i.e. whether this component could actually use it as its own TLS identity. Relevant to both client certificates (mTLS) and server certificates. » member page
property ExternalIFPrivateKeyClass: TExternalIFPrivateKeyClass read FExternalIFPrivateKeyClass write SetExternalIFPrivateKeyClass;
Stores an IF (RSA/DH-style) external-private-key class for this component to potentially use. As of this codebase the value is only stored (read back by application code that set it) - it is not consulted by ValidateMyCert, TLSSetupServer or any handshake code path in this unit, so setting it alone does not change how keys are located; real key lookup goes through PrivateKeyRing. » member page
property TLSSessionCount: Integer read GetTLSSessionCount;
The number of live TLS sessions currently tracked by the internal StreamSecII component (its UserData-keyed session list). Counts both server sessions (TLSAddServerSession/TLSAccept) and client sessions (TLSAddClientSession/TLSConnect) that are open right now. Useful for diagnostics or connection-count limits. » member page
property TLSSessions[index: Integer]: TCustomTLS_ContentLayer read GetTLSSessions;
Indexed access (0..TLSSessionCount-1) to the live TLS session content layers, e.g. to iterate all open connections for monitoring or to force- close idle ones. » member page
property AcceptedCertPolicies: TStrings read GetAcceptedPolicies write SetAcceptedPolicies;
To be published: The certificate-policy OIDs (RFC 5280 policy processing) this component will accept in a validated peer chain; checked against RequiredCertPolicies and the chain's policy extensions/mappings during certificate validation. Applies to whichever chain this instance validates - the server's peer chain when doing mTLS, or the server's own chain when validating it client-side. » member page
property ClientOrServer: TClientOrServer read FClientOrServer write SetClientOrServer;
Declares whether this component instance acts as the TLS client or the TLS server side of the protocol (default cosServerSide on the published descendants). Full description »
property Options: TTLSOptions read GetOptions write SetOptions;
The TTLSOptions block controlling protocol version, cipher suites, key agreement/signature preferences, 0-RTT policy, etc. Configure this before calling TLSSetupServer (server) or before the first TLSConnect (client); TLSSetupServer/TLSSetupClient copy it into the internal StreamSecII component. » member page
property Tls13TicketStore: iTls13TicketStore read GetTls13TicketStore write SetTls13TicketStore;
Where this engine keeps its TLS 1.3 resumption tickets. Delegates straight through to the internal StreamSecII component; never nil, because that component builds itself a private in-memory store. Full description »
property LeanSessionManagement: Boolean read GetLeanSessionManagement write SetLeanSessionManagement;
Delegates straight through to TsmStreamSecII.TLSLeanSessionManagement. As of this codebase that flag is only stored (set here, read back by application code) and is not consulted anywhere in the session/handshake code in this unit, so toggling it has no observable effect on protocol behaviour today. » member page
property RequiredCertPolicies: TStrings read GetRequiredPolicies write SetRequiredPolicies;
The certificate-policy OIDs a peer chain must contain at least one of to be accepted; see AcceptedCertPolicies. Applies to both client-side and server-side chain validation. » member page
property OnTLSChangeCipherSpec: TTLSChangeCipherSpec read FOnTLSChangeCipherSpec write SetOnTLSChangeCipherSpec;
Fired whenever a TLS session (client or server) processes a ChangeCipherSpec message, i.e. right before the cipher suite negotiated for that session starts being used. Mostly useful for logging/diagnostics of the handshake progressing on either side. » member page
property OnTLSCompress: TTLSCompressEvent read FOnCompress write SetOnCompress;
Lets an application plug in a custom TLS-level compression method (rarely used in modern deployments - compression is disabled by default and generally discouraged, e.g. CRIME-style attacks); applies to both client and server sessions when a non-null compression method is negotiated. » member page
property OnTLSDecompress: TTLSDecompressEvent read FOnDecompress write SetOnDecompress;
Counterpart to OnTLSCompress for decompressing incoming records; same caveats apply. » member page
property OnTLSIncomingAlert: TTLSAlertEvent read FOnIncomingAlert write SetOnIncomingAlert;
Fired when a TLS alert arrives from the peer, on either a client or a server session; an application can use this to log/react to protocol errors or a peer-initiated close_notify. On TLS 1.3 a received error alert is fatal whatever its level (RFC 8446 section 6); user_canceled is reported non-fatal and the application decides whether to close. » member page
property OnTLSOutgoingAlert: TTLSAlertEvent read FOnOutgoingAlert write SetOnOutgoingAlert;
Fired when this side sends a TLS alert to the peer, on either a client or a server session; useful for diagnosing why a local handshake/decode operation aborted a connection. Full description »
property OnTLSRenegotiate: TTLSRenegotiateEvent read FOnRenegotiate write SetOnRenegotiate;
Fired when a peer requests (or this side considers) TLS renegotiation; lets an application allow or deny it per session. Applies to both client and server sessions using a protocol version where renegotiation exists (TLS 1.2 and below). » member page
property OnTLSSelectCompression: TTLSSelectCompressionEvent read FOnSelectCompression write SetOnSelectCompression;
Lets an application choose the TLS compression method during negotiation (server side selecting among the client-offered methods); paired with OnTLSCompress/OnTLSDecompress. » member page
property OnTLSEarlyData: TTLSEarlyDataEvent read GetOnTLSEarlyData write SetOnTLSEarlyData;
EARLY DATA (NEW): TLS 1.3 0-RTT events, wrapping StreamSecIIComp. The EarlyData / MaxEarlyDataSize policy lives on Options (TTLSOptions). Server-side only: fires as 0-RTT early application data is received during a resumed handshake, mirroring the EarlyData-stream overloads of TLSAccept/TLSDecodeData for applications that prefer an event-based (rather than stream-based) consumption model. » member page
property OnTLSEndOfEarlyData: TTLSEndOfEarlyDataEvent read GetOnTLSEndOfEarlyData write SetOnTLSEndOfEarlyData;
Server-side only: TLS 1.3 0-RTT event fired once the client's EndOfEarlyData signal has been processed and the connection has moved on to ordinary 1-RTT application data - the boundary an application needs if it is consuming early data via the OnTLSEarlyData event rather than the EarlyData stream parameter. » member page
property OnTLSCheckEarlyDataReplay: TTLSCheckEarlyDataReplayEvent read GetOnTLSCheckEarlyDataReplay write SetOnTLSCheckEarlyDataReplay;
Server-side only: TLS 1.3 0-RTT event that lets an application veto replay of a particular early-data payload (e.g. by checking it against a short-lived cache of already-seen ClientHello/ticket combinations), since 0-RTT data is inherently replayable at the transport level and RFC 8446 leaves anti-replay policy to the application. » member page
property OnTLSNewSessionTicket: TTLSNewSessionTicketEvent read GetOnTLSNewSessionTicket write SetOnTLSNewSessionTicket;
TLS 1.3 (NEW): client-side NewSessionTicket delivery, wrapping StreamSecIIComp.OnTLSNewSessionTicket. Full description »
property OnTLSAddContentLayer: TTLSChangeCipherSpec read GetOnTLSAddContentLayer write SetOnTLSAddContentLayer;
Fired whenever a TLS session (client or server) is added to the internal StreamSecIIComp, before the handshake starts; this is where an application applies per-session settings on the passed content layer (e.g. OfferTLS13, SupportedGroups, ALPN). Wraps StreamSecIIComp.OnTLSAddContentLayer. » member page
property OnTLSHandshakeDone: TTLSChangeCipherSpec read GetOnTLSHandshakeDone write SetOnTLSHandshakeDone;
Fired when a TLS session (client or server) completes its handshake and switches to application data. Wraps StreamSecIIComp.OnTLSHandshakeDone. » member page
property KeyDerivationBits: Integer read FKeyDerivationBits write SetKeyDerivationBits default 10;
Stored for application use; as of this codebase FKeyDerivationBits is only ever written (by this property's setter and by TsmCustomSimpleTLSInternalServer.Create's default of 10) and is not read anywhere in the TLS handshake or key-schedule code, so changing it alone has no observable effect on protocol behaviour. » member page
property IsGlobalServer: Boolean read GetIsGlobalServer write SetIsGlobalServer default False;
Marks this component instance as the process-wide GlobalServer singleton (unit variable) when set True; setting it False again clears GlobalServer only if this instance is currently the one assigned. Full description »
property IncludeRootInTLSChain: Boolean read GetIncludeRootInTLSChain write SetIncludeRootInTLSChain default True;
Controls whether MyCerts includes the trusted root CA certificate at the top of an outgoing certificate chain (some peers/older stacks expect the root to be sent; RFC 8446 discourages it). Applies to the chain this component sends as its own identity, whether that is a TLS server presenting its server certificate or a TLS client presenting a client certificate for mTLS. » member page
property LeastKeyBitSize: Integer read GetLeastKeyBitSize write SetLeastKeyBitSize default 2048;
The minimum acceptable RSA/DSA/DH key size (in bits) enforced across MyCerts, RootCerts and TrustedCerts (and the collected peer-certificate cache) when validating a certificate chain; certificates with a weaker key are rejected. Applies uniformly whether this instance is validating a peer chain as a TLS client or as a TLS server doing mTLS. » member page
property Ocsp: TsmOcsp read FOcsp write SetOcsp;
Ocsp is an OPTIONAL online-revocation client. When assigned, its TrustedCertificates is bound to this server's RootCerts (and unbound on detach) and it is consulted for peer-certificate revocation. Full description »
property RevocationPolicy: TRevocationPolicy read GetRevocationPolicy write SetRevocationPolicy default rpSoftFail;
RevocationPolicy / CRLClockSkew are delegated to RootCerts (the store that owns the CRLs and the Ocsp wiring). See TRevocationPolicy. RevocationPolicy governs what happens when revocation status cannot be determined (soft-fail vs. hard-fail) during peer chain validation, on either the client or the server (mTLS) side. » member page
property CRLClockSkew: Cardinal read GetCRLClockSkew write SetCRLClockSkew default 300;
Allowed clock skew, in seconds, when checking a CRL's thisUpdate/ nextUpdate validity window against local time; widen it if peers/CRL issuers are known to have clocks that drift, to avoid spuriously treating a still-valid CRL as not-yet-valid or expired. Applies to CRL checks on either side of the connection. » member page
property LocalExplicitTrustByDefault: Boolean read FLocalExplicitTrustByDefault write SetLocalExplicitTrustByDefault;
Default explicit-trust flag applied when this component (rather than the peer) locally adds a certificate to a trust store, e.g. via LoadTrustedCertsFromFile/LoadRootCertsFromFile, letting an application pre-seed pinned/trusted certificates without answering an OnCertNotTrusted prompt for each one. » member page
property MyCertList: TCertificateCollection read GetMyCertList write SetMyCertList;
This component's own certificate collection (its TLS identity: server certificate, or client certificate for mTLS). An application populates this directly, or indirectly via ImportFromPFX/LoadMyCertsFromFile, and must pair each certificate here with a private key reachable through PrivateKeyRing. » member page
property MyCertsGroupIndex: Integer read GetMyCertsGroupIndex write SetMyCertsGroupIndex default -1;
Used together with MyCertsSource to make this component's MyCerts a filtered view (a "hijacker", see UpdateHijacker) of another TsmCustomX509TrustedCertificates-derived component's certificate list - i.e. share one central certificate store across several TLS components instead of loading the sam... Full description »
property MyCertsSource: TsmCustomX509TrustedCertificates read GetMyCertsSource write SetMyCertsSource;
The component MyCerts should source its certificates from when MyCertsGroupIndex is non-negative; see MyCertsGroupIndex. » member page
property PrivateKeyRing: TsmPrivateKeyRingComponent read GetPrivateKeyRing write SetPrivateKeyRing;
The private-key store used to find/hold the private keys matching MyCerts entries (see ValidateMyCert, TLSSetupServer). Full description »
property PublicKeyAlgorithms: TPublicKeyAlgs read FPublicKeyAlgorithms write SetPublicKeyAlgorithms;
The set of public-key algorithms this component is currently willing to use, recomputed by ValidatePublicKeyPairs whenever ClientOrServer, MyCertsSource or MyCertList changes. Full description »
property RootCertList: TCertificateCollection read GetRootCertList write SetRootCertList;
The trusted root/CA certificates used to validate the peer's certificate chain (as opposed to MyCertList, this component's own identity). An application populates this via LoadRootCertsFromFile/ LoadRootCertsFromStream or by assignment. Applies on both sides: a client validating a server's chain, or a server validating a client's chain under mTLS. » member page
property RootCertsGroupIndex: Integer read GetRootCertsGroupIndex write SetRootCertsGroupIndex default -1;
Analogous to MyCertsGroupIndex, but for RootCerts: makes RootCerts a filtered view of another component's certificate list instead of owning its own trust anchors, when non-negative. » member page
property RootCertsSource: TsmCustomX509TrustedCertificates read GetRootCertsSource write SetRootCertsSource;
The component RootCerts should source its certificates from when RootCertsGroupIndex is non-negative; see RootCertsGroupIndex. » member page
property SessionKeyLifeSpan: System.TTime read GetSessionKeyLifeSpan write SetSessionKeyLifeSpan;
How long a TLS session (its resumption key/ticket state) is kept alive before it is treated as expired, e.g. by ClearExpiredSessionKeys. Applies to session resumption on both the client side (cached tickets/session IDs) and the server side (its session cache / issued tickets). » member page
property BeforeImportTLSCert: TBeforeImportTLSCertEvent read GetBeforeImportTLSCert write SetBeforeImportTLSCert;
Fires when a peer's TLS Certificate message is imported into CollectedCertificates during a handshake (ImportChainFromTLS), before the peer's leaf is checked, letting the application mark that leaf as explicitly trusted or allow it to be expired. It does not fire for ImportFromPFX or any other import of this component's own PFX. » member page
property OnCertNotTrusted: TCertNotTrustedEvent read FOnCertNotTrusted write SetOnCertNotTrusted;
Fires when a peer certificate chain fails the normal trust check (no path to a trusted root), letting an application decide at runtime whether to explicitly trust it anyway (e.g. an interactive "accept this certificate" prompt, or pinning logic). Full description »
property OnCertNotAccepted: TCertNotAcceptedEvent read FOnCertNotAccepted write SetOnCertNotAccepted;
Fires when a peer certificate is rejected for a reason other than plain trust (e.g. expired, revoked, wrong key usage), letting an application decide whether to retry validation (aRetry). Like OnCertNotTrusted, this applies to whichever side is validating the other's certificate. » member page

classTsmTLSInternalServer — component reference

inherits from TsmCustomTLSInternalServer

property AcceptedCertPolicies;
Republished (see TsmCustomTLSInternalServer.AcceptedCertPolicies): this is the general-purpose published TLS server/client component, so the full certificate-policy control surface is exposed here. » member page
property ClientOrServer default cosServerSide;
Republished with a cosServerSide default (see TsmCustomTLSInternalServer.ClientOrServer); an application must switch this to cosClientSide explicitly to use this component to originate connections instead of accepting them. » member page
property Options;
Republished (see TsmCustomTLSInternalServer.Options). » member page
property RequiredCertPolicies;
Republished (see TsmCustomTLSInternalServer.RequiredCertPolicies). » member page
property TrustedCertList;
Republished (see TsmCustomTLSInternalServer.TrustedCertList, which delegates to the TrustedCerts store): certificates trusted directly without a chain to a root. » member page
property TrustedCertsGroupIndex default -1;
Republished; non-negative value makes TrustedCertList a filtered view of TrustedCertsSource instead of owning its own list (same "hijacker" pattern as MyCertsGroupIndex/RootCertsGroupIndex). » member page
property TrustedCertsSource;
Republished: the component TrustedCertList sources from when TrustedCertsGroupIndex is non-negative. » member page
property OnCertPolicy;
Republished: lets an application accept/reject a peer certificate based on its policy extensions during chain validation, on either side. » member page
property OnTLSChangeCipherSpec;
Republished (see TsmCustomTLSInternalServer.OnTLSChangeCipherSpec). » member page
property OnTLSCompress;
Republished (see TsmCustomTLSInternalServer.OnTLSCompress). » member page
property OnTLSDecompress;
Republished (see TsmCustomTLSInternalServer.OnTLSDecompress). » member page
property OnTLSIncomingAlert;
Republished (see TsmCustomTLSInternalServer.OnTLSIncomingAlert). » member page
property OnTLSOutgoingAlert;
Republished (see TsmCustomTLSInternalServer.OnTLSOutgoingAlert). » member page
property OnTLSRenegotiate;
Republished (see TsmCustomTLSInternalServer.OnTLSRenegotiate). » member page
property OnTLSSelectCompression;
Republished (see TsmCustomTLSInternalServer.OnTLSSelectCompression). » member page
property OnTLSEarlyData;
Republished, server-side-only in effect (see TsmCustomTLSInternalServer.OnTLSEarlyData): fires for TLS 1.3 0-RTT data received while this component is accepting connections. » member page
property OnTLSEndOfEarlyData;
Republished, server-side-only in effect (see TsmCustomTLSInternalServer.OnTLSEndOfEarlyData). » member page
property OnTLSCheckEarlyDataReplay;
Republished, server-side-only in effect (see TsmCustomTLSInternalServer.OnTLSCheckEarlyDataReplay). » member page
property OnTLSNewSessionTicket;
Republished, client-side in effect (see TsmCustomTLSInternalServer.OnTLSNewSessionTicket). » member page
property OnTLSAddContentLayer;
Republished (see TsmCustomTLSInternalServer.OnTLSAddContentLayer). » member page
property OnTLSHandshakeDone;
Republished (see TsmCustomTLSInternalServer.OnTLSHandshakeDone). » member page
property OnWorkerError; property OnWorkerFatal;

classTsmCustomSimpleTLSInternalServer

inherits from TsmCustomTLSInternalServer

constructor Create(AOwner: TComponent); override;
Creates the component with server-oriented cipher-suite defaults preset (AES128 and DHE preferred, AES256 and ECDHE allowed, 256-bit ephemeral EC key size) so a "simple" TLS server (this class backs the published TsmSimpleTLSInternalServer component) works reasonably out of the box without an application tuning every Options field by hand. » member page
destructor Destroy; override;
Inherited destructor; no additional teardown of its own beyond what TsmCustomTLSInternalServer.Destroy already does. » member page
property ClientOrServer default cosServerSide;
Overrides the inherited ClientOrServer to default to cosServerSide, matching this class's role as a ready-to-use TLS server (as opposed to a general client-or-server component where the application must choose). » member page
property KeyDerivationBits default 10;
Overrides the inherited KeyDerivationBits to default to 10; as noted on the base property, this value is currently only stored and not consulted by any handshake/key-schedule code in this unit. » member page

classTsmSimpleTLSInternalServer — component reference

inherits from TsmCustomSimpleTLSInternalServer

property Options;
Republished (see TsmCustomTLSInternalServer.Options); pre-populated with this class's simple-server cipher defaults set up in Create. » member page
property TrustedCertList;
Republished (see TsmCustomTLSInternalServer.TrustedCertList via TrustedCerts): pin trusted peer certificates for this simple server. » member page
property TrustedCertsGroupIndex default -1;
Republished (see TsmCustomTLSInternalServer.TrustedCertsGroupIndex): non-negative makes TrustedCertList a filtered view of TrustedCertsSource. » member page
property TrustedCertsSource;
Republished: the component TrustedCertList sources from when TrustedCertsGroupIndex is non-negative. » member page
property UserList;
Republished (see TsmCustomSimpleTLSInternalServer.UserList): an application assigns a user-list component here for whatever user-authentication scheme this simple server layers on top of TLS; freeing that component clears this reference via Notification. » member page
property OnCertPolicy;
Republished (see TsmCustomTLSInternalServer.OnCertPolicy). » member page
property OnTLSChangeCipherSpec;
Republished (see TsmCustomTLSInternalServer.OnTLSChangeCipherSpec). » member page
property OnTLSCompress;
Republished (see TsmCustomTLSInternalServer.OnTLSCompress). » member page
property OnTLSDecompress;
Republished (see TsmCustomTLSInternalServer.OnTLSDecompress). » member page
property OnTLSIncomingAlert;
Republished (see TsmCustomTLSInternalServer.OnTLSIncomingAlert). » member page
property OnTLSOutgoingAlert;
Republished (see TsmCustomTLSInternalServer.OnTLSOutgoingAlert). » member page
property OnTLSRenegotiate;
Republished (see TsmCustomTLSInternalServer.OnTLSRenegotiate). » member page
property OnTLSSelectCompression;
Republished (see TsmCustomTLSInternalServer.OnTLSSelectCompression). » member page
property OnTLSEarlyData;
Republished, server-side-only in effect (see TsmCustomTLSInternalServer.OnTLSEarlyData). » member page
property OnTLSEndOfEarlyData;
Republished, server-side-only in effect (see TsmCustomTLSInternalServer.OnTLSEndOfEarlyData). » member page
property OnTLSCheckEarlyDataReplay;
Republished, server-side-only in effect (see TsmCustomTLSInternalServer.OnTLSCheckEarlyDataReplay). » member page
property OnTLSNewSessionTicket;
Republished, client-side in effect (see TsmCustomTLSInternalServer.OnTLSNewSessionTicket). » member page
property OnTLSAddContentLayer;
Republished (see TsmCustomTLSInternalServer.OnTLSAddContentLayer). » member page
property OnTLSHandshakeDone;
Republished (see TsmCustomTLSInternalServer.OnTLSHandshakeDone). » member page
property OnWorkerError; property OnWorkerFatal;

Types (enumerations, sets, aliases)

typeTCustomTLS_ContentLayer

  TCustomTLS_ContentLayer = StreamSec.Mobile.TlsClass.TCustomTLS_ContentLayer;

procTStreamEvent

  TStreamEvent = procedure (Sender: TObject; AStream: TStream) of object;

typeTPublicKeyAlg

  TPublicKeyAlg = StreamSec.Mobile.X509Comp.TPublicKeyAlg;

setTPublicKeyAlgs

  TPublicKeyAlgs = set of TPublicKeyAlg;

enumTClientOrServer

  TClientOrServer = (cosServerSide,cosClientSide);

procTSleepProc

  TSleepProc = procedure (Milliseconds: Cardinal);

Routines