fix(testing): escape XML-invalid characters in JUnit reports

A theory case containing a control character crashed the JUnit writer
after every test had passed, failing the Data test step on all runners.

Also clears a stale rejected certificate fingerprint once a later
handshake is accepted or the fingerprint is trusted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 10:43:36 +00:00
1 parent 95dbf53569
commit 3223c8af39
2 files changed
+48 -12

No files matched your search

@@ -6,25 +6,39 @@ namespace Titano.Protocol.Client;
/// <summary>
/// Trust-on-first-use certificate validation: a certificate is accepted when it chains to a trusted root or when
/// its SHA-256 fingerprint is in the caller's trusted set. The last unknown fingerprint is remembered so the UI can
/// ask the user once and add it.
/// its SHA-256 fingerprint is in the caller's trusted set. The fingerprint rejected by the latest handshake is
/// remembered (and cleared by the next accepted one) so the UI can ask the user once and add it.
/// </summary>
public sealed class CertificatePinning(IEnumerable<string> trustedFingerprints)
{
private readonly HashSet<string> _trusted = new(trustedFingerprints.Select(Normalize), StringComparer.Ordinal);
private readonly Lock _gate = new();
private string? _lastRejected;
public string? LastRejectedFingerprint { get; private set; }
public string? LastRejectedFingerprint
{
get { lock (_gate) return _lastRejected; }
}
public void Trust(string fingerprint) => _trusted.Add(Normalize(fingerprint));
public void Trust(string fingerprint)
{
lock (_gate)
{
_trusted.Add(Normalize(fingerprint));
_lastRejected = null;
}
}
public bool Validate(object sender, X509Certificate? certificate, X509Chain? chain, SslPolicyErrors errors)
{
if (certificate is null) return false;
if (errors == SslPolicyErrors.None) return true;
var fingerprint = Fingerprint(certificate);
if (_trusted.Contains(fingerprint)) return true;
LastRejectedFingerprint = fingerprint;
return false;
var fingerprint = errors == SslPolicyErrors.None ? null : Fingerprint(certificate);
lock (_gate)
{
var accepted = fingerprint is null || _trusted.Contains(fingerprint);
_lastRejected = accepted ? null : fingerprint;
return accepted;
}
}
public static string Fingerprint(X509Certificate certificate) =>