Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mobile.PlainTextResources

Feature notes: TLS implementation notes (RFC map)

Classes, interfaces and records

recordtPlainTextRule

ONE LINE OF THE CLEARTEXT SURFACE.

Host exact and case-insensitive; '' matches any host. Naming the host is the difference between "the PKI subdomain serves CRLs" and "this server serves CRLs", which is the distinction an audit turns on. Path an exact path, or a prefix when it ends in '/'.

Host : string; Path : string; Kind : tPlainTextKind; Source : string;
ptkStaticFile: the file. ptkOcspCache: unused.
ContentType: string; MaxAgeSecs : Integer;
Cache-Control: public, max-age=N

interfaceiPlainTextOcspCache

The pre-signed OCSP responses, keyed by the base64url request string exactly as it arrives in the URL. Implemented by whoever owns the CA; this unit only reads it.

Lookup MUST be cheap and MUST NOT block: it is called from a plaintext worker thread holding one of a small number of slots. An implementation that consults a database on a miss has reintroduced the very cost this design removes.

function Lookup(const aRequest: string; out aResponse: TBytes): Boolean; function Ready: Boolean;

classtPlainTextOcspCache

inherits from TInterfacedObject

implements iPlainTextOcspCache

A default in-memory cache. The producer calls Publish for each response it has signed; readers never block on the producer for longer than a copy.

constructor Create; destructor Destroy; override; function Lookup(const aRequest: string; out aResponse: TBytes): Boolean; function Ready: Boolean; procedure Publish(const aRequest: string; const aResponse: TBytes); procedure BeginPublish; procedure EndPublish; function Count: Integer; function LoadFromDirectory(const aDir: string; out aRejected: Integer): Integer;
Load a published set from disk. See the format note in the implementation. Returns how many entries were taken; aRejected counts files that were present but unusable, which is a number worth logging rather than a reason to fail. Never raises: a responder that refuses to start because one file is corrupt has turned a partial outage into a total one.

recordtPlainTextAnswer

The answer this unit gives the redirect handler. Status 0 means "not mine, redirect as usual" - the fall-through that keeps the existing behaviour the default.

Status : Integer; Body : TBytes; ContentType: string; MaxAgeSecs : Integer;

classtPlainTextRules

constructor Create; destructor Destroy; override; procedure AddRule(const aRule: tPlainTextRule); overload; procedure AddStaticFile(const aHost, aPath, aFile, aContentType: string; aMaxAgeSecs: Integer); procedure AddOcsp(const aHost, aPathPrefix: string; aMaxAgeSecs: Integer); procedure Clear; function RuleCount: Integer; function Rule(aIndex: Integer): tPlainTextRule; function Answer(const aHost, aPath, aQuery: string; out aAnswer: tPlainTextAnswer): Boolean;
The whole job: given a parsed request head, either produce an answer or say "redirect". Never raises, never blocks on I/O beyond one cached file read, never signs, never parses the query.
function Claims(const aHost, aPath: string): Boolean;
Does any rule claim this? Cheap, and separate from Answer so a caller can decide to refuse BEFORE doing the work.
function TryEnter: Boolean;
Reserve one of the resource write slots. MUST be paired with Leave in a try/finally, and MUST straddle the write rather than just the lookup - the write is the part being bounded.
procedure Leave; function BusyAnswer: tPlainTextAnswer;
The refusal, when the resource slots are full. Small, uncacheable, and it names a retry delay so a well-behaved client backs off instead of hammering.
property Ocsp: iPlainTextOcspCache read fOcsp write fOcsp;
ASSIGNING THIS TRANSFERS OWNERSHIP TO THE REFERENCE COUNT. The field is an interface, and tPlainTextOcspCache is a TInterfacedObject, so the cache is freed when the last reference goes - which happens when this object is destroyed. Full description »
property MaxResourceSlots: Integer read fMaxResourceSlots write fMaxResourceSlots; property ResourceLive: Integer read fResourceLive;

Types (enumerations, sets, aliases)

enumtPlainTextKind

  tPlainTextKind = (
    ptkStaticFile,   // bytes from a file, cached in memory, mtime-checked
    ptkOcspCache);   // pre-signed responses, memory only, never a file read

Routines