Python 3.12 SSL compatibility: ssl.wrap_socket removed
Problem
Python 3.12 removed the deprecated ssl.wrap_socket() function, causing Nettacker's SSL scanning functionality to fail on Python 3.12+.
Impact
- SSL weak version detection broken
- SSL weak cipher detection broken
- Users on Python 3.12+ cannot use Nettacker
Root Cause
The deprecated ssl.wrap_socket() was removed in Python 3.12. Nettacker needs to use the modern ssl.SSLContext().wrap_socket() API instead.
Solution
Replace ssl.wrap_socket() with ssl.SSLContext().wrap_socket() throughout the codebase with proper certificate verification settings.
Testing Completed
- ✅ Full Nettacker scan completed successfully on Python 3.12.3
- ✅ All 117 modules loaded without errors
- ✅ SSL weak version detection confirmed working
- ✅ SSL weak cipher detection confirmed working
- ✅ Port scanning executed correctly (1005 requests)
- ✅ Report generation successful
- ✅ Zero Python 3.12 compatibility errors
Related PR
- PR #1177: Implementation of this fix
@arkid15r, please assign this to me so I can track the fix in PR #1177
Hi! I'm a GSoC 2026 applicant. I investigated this issue and also commented on the related issue #1302.
Reproduced on Python 3.12.3 (WSL2, Ubuntu 24.04) and verified PR #1177 fixes the problem:
- Before: 285 passed, 2 failed ❌
- After: 287 passed, 0 failed ✅
It may also be worth updating PR #1177 to reference
Fixes #1302 so both issues close automatically on merge.
Happy to help with any additional testing!
@arkid15r I was able to reproduce the root cause and I'm aware there are 4 related PRs open right now but majority of them are stale, #1177 is the closest to mergeable but it's blocked cause of a bug too. Can you assign me so I could continue work on the existing (stale) PR?
@arkid15r I was able to reproduce the root cause and I'm aware there are 4 related PRs open right now but majority of them are stale, #1177 is the closest to mergeable but it's blocked cause of a bug too. Can you assign me so I could continue work on the existing (stale) PR?
Hi @faneeshh Yes, it'd be great to have it resolved. However, I normally leave it to @securestep9 to balance the workload and assign issues atm.
@arkid15r I was able to reproduce the root cause and I'm aware there are 4 related PRs open right now but majority of them are stale, #1177 is the closest to mergeable but it's blocked cause of a bug too. Can you assign me so I could continue work on the existing (stale) PR?
cc @securestep9
@faneeshh what is your plan for addressing it - do you have a working Nettacker in your lab with SSL module correctly working and detecting outdated TLS and weak ciphers?
@faneeshh we also need to preserve backward compatibility with Python 3.11 as this is the version of Python officially supported by Nettacker, so rewriting the SSL functionality so it works on Python 3.12 but gets broken in 3.11 is not a solution - please do bear that in mind
@faneeshh what is your plan for addressing it - do you have a working Nettacker in your lab with SSL module correctly working and detecting outdated TLS and weak ciphers?
So I just ran a few tests and I'll just give you an overview of my observations :
-
Backward compat with 3.10/3.11 is fine, the newer SSL APIs all work the same across versions, no issue there.
-
The important thing probably: I traced how
ssl_flagis used and there's actually two differentcreate_tcp_socket( )functions doing different jobs. The one insocket.pyjust usesssl_flagfor logging, so it's fine to lock down to modern TLS only. But the one inssl.pyis what gates whether the weak version/weak cipher checks even run.
if that one fails to connect, the checks just get skipped silently. So that one needs to stay open, so that means no minimum version, same as is_weak_cipher_suite( ) already does.
I also did run a fake TLS 1.0-only server locally and tried connecting to it the same way is_weak_ssl_version() does. It just doesn't work cause modern OpenSSL refuses to even attempt a TLS 1.0 or 1.1 handshake anymore at the library level, regardless of what Python asks for. I tested this on two different machines (Linux and Windows) and got slightly different error messages but the same result both times. TLS 1.2 still detects fine as a control.
So basically even after fixing the wrap_socket removal, the TLS 1.0/1.1 weak version checks specifically are quietly broken on any modern machine running Nettacker, separate from the Python 3.12 issue. It'll say "not weak" even against a target that's still running TLS 1.0, because the scanning machine's own OpenSSL won't let it try.
Feels like there might be two separate issues here: the wrap_socket fix, and this OpenSSL-level TLS1.0/1.1 thing. Should I open a seperate issue for that or keep it under this?
@securestep9 I have a working solution locally on my laptop. I believe the policy is to be assigned to an issue before creating a PR?