fix(agent/get.ps1): narrow overly-broad TLS-failure classification regex (#962) #31
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
primatekuntech/triton-install!31
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/962-tls-classification-regex"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes the bug behind mirrored triton-repo issue #962 (read-only, from
git.antrapol.tech — not edited/commented/closed there; this PR is the
record).
The bug
$TlsDetail -match 'inner exception|CERT_AUTHORITY_INVALID|CA'wasunintentionally unconditional: PowerShell wraps every .NET
method-invocation exception in boilerplate text like
Exception calling "AuthenticateAsClient" with "1" argument(s):— and"AuthenticateAsClient" itself contains the substring "ca"
(case-insensitive) — so the bare
CAalternative matched literallyany exception this call site could throw, not just a genuine CA/trust
mismatch.
inner exceptionis equally generic — SSPI auth failuresroutinely wrap with "see inner exception" regardless of cause.
Confirmed empirically, not guessed: a synthetic "connection forcibly
closed" exception (nothing to do with CA trust) matched the old
pattern too, in a real
pwshtest.The fix
Narrowed to the actual, verified message
System.Net.Security.SslStream's own cross-platform managed codeproduces specifically when the custom
RemoteCertificateValidationCallbackreturns
$false:Confirmed by direct testing against a real
SslStreamhandshake(self-signed cert +
TcpListener+ a callback that deliberatelyreturns false) — not assumed from documentation. Since this message
comes from .NET's shared managed layer (not the OS-specific
SChannel/OpenSSL backend), it should be reliable on Windows too. Kept
CERT_AUTHORITY_INVALIDas a secondary fallback (a specificCAPI/Win32 error constant, low false-positive risk).
Caveat: I could not empirically verify Windows/SChannel's exact
text for the benign "no client cert yet" mTLS-rejection case without a
real Windows box — on this Mac's OpenSSL-backed .NET runtime that case
doesn't even throw client-side at all, so cross-platform testing has a
real limit here. The fix doesn't need to positively match that case,
only to stop false-matching it: narrowing away the generic
inner exception/bare-CAalternatives achieves that regardless of whatWindows's actual benign-case text turns out to be.
$TlsDetailis used only for this one classification check, neverdisplayed to the user, so no other code path is affected.
Testing
This repo has no test harness for
.ps1files. Verified via athrowaway
pwshscript (not committed): the old pattern matches botha real captured CA-rejection message and a synthetic unrelated one;
the new pattern matches only the former. PowerShell AST parse clean;
PSScriptAnalyzershows only pre-existing warnings unrelated to thischange.
$SCRIPT_VERSIONbumped 1.3.9 → 1.3.10.🤖 Generated with Claude Code