tls: add optional server certificate verification - #5144
Open
KernelClint wants to merge 5 commits into
Open
KernelClint wants to merge 5 commits into
KernelClint wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5144 +/- ##
==========================================
- Coverage 80.92% 80.35% -0.58%
==========================================
Files 393 393
Lines 98107 98197 +90
==========================================
- Hits 79392 78902 -490
- Misses 18715 19295 +580
🚀 New features to boost your workflow:
|
gpotter2
reviewed
Sep 3, 2026
KernelClint
force-pushed
the
tls-optional-server-verification
branch
from
September 8, 2026 16:59
de83345 to
4fa7ce6
Compare
gpotter2
previously approved these changes
Sep 8, 2026
Member
|
It also seems the test against |
KernelClint
force-pushed
the
tls-optional-server-verification
branch
2 times, most recently
from
September 9, 2026 17:25
35b9c0e to
a1e3f3a
Compare
AI-Assisted: yes (GPT-5.6-Cyber)
Verification defaulted to on, which changed behaviour for every existing caller: this client is routinely pointed at servers whose certificates are not meant to verify. It is now off unless asked for, which is what the existing tests wanted -- the six verify=False opt-outs they needed are gone. Passing cafile turns it on, since supplying a CA and getting no checking would be worse than either. A refusal logged only "verification failed". It now logs which check failed, alongside the other TLS refusals. AI-Assisted: yes (gpt-5.6-sol)
KernelClint
force-pushed
the
tls-optional-server-verification
branch
from
September 24, 2026 12:10
a1e3f3a to
7687168
Compare
gpotter2
reviewed
Sep 24, 2026
CertTree.verify() and CMS_Engine.verify() gain allow_expired, defaulting to False so the expiry check stays on everywhere it already was. A CMS signature is usually checked long after it was made, and the PKINIT tests are a real captured MIT Kerberos exchange whose client certificate was valid 2025-09-20 to 2026-09-20. The signature it carries is genuine; only the clock has moved on, so those two tests pass allow_expired=True. AI-Assisted: yes
gpotter2
reviewed
Sep 24, 2026
gpotter2
left a comment
Member
There was a problem hiding this comment.
Sorry, I still have comments :( Thanks again for the work and sorry about that
AI-Assisted: no
gpotter2
force-pushed
the
tls-optional-server-verification
branch
from
September 26, 2026 16:11
8443440 to
b86b26c
Compare
AI-Assisted: no
gpotter2
force-pushed
the
tls-optional-server-verification
branch
from
September 26, 2026 16:13
b86b26c to
e591fc1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLSClientAutomatoncompletes a handshake and sends application data without checking the server'scertificate against a trust store or the hostname it asked for. It is a test client, and it does
not claim otherwise — but there is no way to ask it to check, which makes it awkward to use against
a real service where that is the point.
The relevant states pass the certificate through without a policy:
scapy/layers/tls/automaton_cli.py:118-142takes the server name but has no trust store, and
:396-405advances past a TLS 1.2 Certificatemessage without authenticating it.
The change adds verification and makes it selectable. When enabled, an explicit CA bundle is used if
one is supplied and the system trust store otherwise, the requested hostname is checked, and the
connection closes on failure.
verify=Falsekeeps the current behaviour for the cases wheretalking to an untrusted server is the whole point of the exercise.
The added regressions cover a self-signed server, a valid certificate for the wrong hostname, and a
correct server, asserting the first two close the connection and the third completes. Without the
source change they fail.
On cost. Performance was measured on one computer, before and after the fix, but there is not
much of a "before" to measure: the client performs no verification today, so its valid path does
nothing. Verifying took 2.9 µs per handshake, against 819 ns of test overhead — roughly 2.1 µs
added, once per connection, for a full chain and hostname check. A percentage against a path that
does no work would not mean anything, so none is quoted.