advanced28 min studyLesson 220 in Engineering

Test the rejection path as carefully as the happy path

Build an explicit TLS test matrix for names, trust, versions, fallback, and termination layers without mistaking diagnostic continuation or a clean sample for proof.

On this page

What you’ll understand

  • Define allowed and rejected protocol outcomes under a documented deployment policy.
  • Separate SNI routing, identity verification, and diagnostic-tool continuation.
  • Measure coverage of specified cases without inventing a percentage-secure score.

A browser showing a successful encrypted connection exercises one path through one configuration. It does not show that the client rejects an impostor, that legacy fallback is forbidden where policy requires it, or that an origin bypass has the same checks as the public edge. Misconfiguration testing turns these unproven assumptions into explicit cases with expected outcomes. Run the cases against an authorized test environment and verify the application's behavior after failure, not merely whether a library printed a warning.

State the policy before labeling a downgrade

TLS negotiation chooses parameters from the supported and permitted sets. A deployment must document its allowed protocol versions, algorithms, identity rules, and application protocols. A connection using a version permitted by that policy is not automatically evidence of a successful downgrade attack. Conversely, a client that retries over plaintext or deliberately disables verification after a failure can bypass the intended boundary regardless of a secure first attempt. Test that the failure is terminal where policy requires authenticated encrypted transport.

TLS 1.3 includes transcript and version-negotiation protections against specified active interference, but these mechanisms cannot make an application's explicitly insecure fallback safe. For a fictional service whose policy requires TLS 1.3, test successful allowed negotiation and rejection when only an excluded version is offered. Keep the test's premise separate from a universal recommendation for every deployment. Record the actual endpoint, negotiated version, cipher, ALPN, certificate identity, and whether resumption or early data changed the path being exercised.

Vnegotiated∈Vclient∩Vserver∩VpolicyV_{\rm negotiated}\in V_{\rm client}\cap V_{\rm server}\cap V_{\rm policy}
The sets represent offered, supported, and explicitly permitted versions in a simplified successful-negotiation model. Membership alone does not prove correct authentication or the absence of implementation defects; a policy may require the intersection to be nonempty and reject rather than fall back outside it.↔ Scroll wide equations horizontally.

Negative fixtures isolate individual checks

Use otherwise comparable certificate fixtures to test an unknown issuer, a wrong exact service name, an expired or not-yet-valid certificate, and prohibited purpose or constraints. One failure can mask another: a wrong-name certificate under an unknown issuer cannot demonstrate that name checking runs, because the path may fail first. Add positive controls so an unreachable listener is not miscounted as successful security rejection. Test each termination leg and relevant client configuration, since a proxy can pass its checks while a direct origin or background worker bypasses them.

OpenSSL's s_client is a diagnostic tool that can continue after verification errors unless configured to return them. In a controlled local test, options such as -verify_return_error and -verify_hostname api.example.test express checks that merely setting -servername api.example.test does not. SNI chooses the virtual-host context; it is not the identity-verification instruction. Inspect the tool's documented behavior and exit outcome for the installed version, and test the real application's verification callback too. A successful diagnostic handshake with an error message is not evidence of correct production rejection.

Cspecified=Nexecuted specifiedNspecifiedC_{\rm specified}=\frac{N_{\rm executed\ specified}}{N_{\rm specified}}
This dimensionless ratio measures execution coverage of a declared finite test matrix. It does not measure security, account for missing cases, or turn unexpected acceptance into success. Expected outcomes and actual results must be assessed separately.↔ Scroll wide equations horizontally.

Preserve evidence and challenge its scope

For each case retain the expected outcome, actual failure stage, selected identity and trust configuration, and sanitized logs. Avoid recording private keys or reusable session secrets to make a convenient report. A regression should replay the relevant configuration and fixture so that a future permissive callback, forgotten minimum-version setting, or proxy exception is caught. When all declared cases pass, review whether the matrix omitted a materially different route, client type, trust store, resumption path, or fallback behavior. Passing an incomplete matrix cannot establish the missing boundary.

The sampling lab compares a deliberately synthetic independent-test model. Reset, set both p=0.02 and n=20, predict the exact zero-detection probability, then inspect and Play or Step. Reset again and set both p=0.02 and n=100 for a separate comparison. Playback highlights outcomes; it does not collect random tests. The exact zero bar falls from about 0.668 to 0.133. Ignore normal bars for this rare-event question and use the exact distribution. Real targeted security cases are not interchangeable independent draws, so the calculation motivates coverage scrutiny rather than certifying a system.

Count cases without calling the result a security score

Two authorized TLS termination paths each have six specified checks: a positive control, wrong-name rejection, unknown-issuer rejection, expired-certificate rejection, allowed-version success, and excluded-version rejection. All twelve run; two negative cases unexpectedly accept.

  1. The declared matrix has 2 × 6 = 12 cases. Running all twelve gives 12/12 = 100% execution coverage of this declared matrix, not complete coverage of every possible configuration.

  2. Ten outcomes match expectations and two do not, so the outcome-match fraction is 10/12 ≈ 83.3%. The two unexpected acceptances remain actionable failures; the system is not '83.3% secure.'

  3. Inspect which layer accepted each negative case and reproduce it with isolated fixtures. Fix the relevant verification or policy behavior, rerun the affected cases and controls, and review whether a shared configuration exposes additional paths.

The result

The matrix was fully executed but failed two rejection requirements. Coverage and correctness are distinct, and neither percentage alone describes overall security.

Explore the model

Interactive lab

Interactive lab · sampling

More tests do not erase untested assumptions

Compare fresh Reset → set both p=0.02,n=20 and Reset → set both p=0.02,n=100 cases. Predict exact zero-detection probabilities before inspecting and using Play/Step. Playback highlights binomial outcomes, not real sampled tests; use exact bars rather than the normal approximation here.

More tests do not erase untested assumptionsExact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Current readings: Mean sample proportion: 0.5; Sample-mean variance: 0.0125; Uniform CDF error bound: ≤ 0.1062. All parameters are adjustable with the labeled controls below.Exact distribution of the mean of 20 independent Bernoulli variables with success probability 0.5; playback highlights outcome 0.00.250.50.75100.0580.1150.1730.23Sample mean · k / nProbability massNormal bin masses are an approximationk = 0 · exact probability = 9.54e-7
Exact binomial massNormal interval massHighlighted outcome / mean
Mean sample proportion
0.5
Sample-mean variance
0.0125
Uniform CDF error bound
≤ 0.1062
t = 0 s

Exact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA clean run is conditional evidence; explicit negative fixtures and complete boundary coverage remain necessary.

Check your understanding

s_client reports a certificate verification error but continues the diagnostic handshake. What does that observation establish?

Try it yourself

A client tries authenticated TLS, receives an identity mismatch, then automatically retries the same sensitive request over plaintext. The secure endpoint's certificate tests all pass. Which requirement still fails, and what regression should capture it?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Follow the application's behavior after verification fails, rather than evaluating only the secure server's happy path.

Compare with the solution

The application fails the requirement to keep the sensitive request on authenticated encrypted transport: fallback bypasses the rejected identity boundary. A controlled regression should provoke the mismatch, require a terminal failure for that request, and confirm that no plaintext or verification-disabled retry is sent. Keep a valid-identity positive control so the test distinguishes deliberate fail-closed behavior from a generally broken connection path.

Take it with you

  • Negotiation tests need a documented version and authentication policy.
  • Diagnostic warnings, SNI, and completed handshakes do not prove enforced verification.
  • Execution coverage and expected-outcome correctness are separate from an overall security claim.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.