Tests fail on Python 3.12: `ssl.wrap_socket` removed
Two tests fail on Python 3.12 because they patch ssl.wrap_socket, which was removed in Python 3.12:
- tests/core/lib/test_ssl.py::TestSslMethod::test_create_tcp_socket
- tests/core/lib/test_socket.py::TestSocketMethod::test_create_tcp_socket
Error message:
AttributeError: <module 'ssl' from '.../python3.12/ssl.py'> does not have the attribute 'wrap_socket'
I believe this is mainly because Python 3.12 removed the deprecated ssl.wrap_socket() API (deprecated since 3.7).
Environment: Python 3.12.8 Project supports Python 3.10–3.12 per pyproject.toml (python = "^3.10, <3.13") and docs
I will try to fix this issue with recommanded ssl.SSLContext
Hi @kwei-zhang , I would like to work on this issue if it is not already in progress. Please let me know if I can proceed.
Hi @yashasvi290906 , I would like to mention that the best way to learn and contribute to this project is to use this tool and then try to contribute in aspects which could have been better as per your experience .
I’ve gone through this issue and understand the problem related to ssl.wrap_socket removal in Python 3.12. I would like to work on fixing this by updating the tests for compatibility.
Hello! I'am a GSoC 2026 participant and posting my first ever comment on an open source issue and after brief thought and investigation here i am posting for this issue.
Investigation Process:
- cloned the repo and reproduced the issue locally on my machine using python 3.12.3 running on WSL2 (Ubuntu 24.04) and confirmed the issues mentioned previously by fellow contributors given below :
-tests/core/lib/test_ssl.py::TestSslMethod::test_create_tcp_socket
-tests/core/lib/test_socket.py::TestSocketMethod::test_create_tcp_socket
2.Traced the root cause through the codebase:
-nettacker/core/lib/socket.py:29 → ssl.wrap_socket()
-nettacker/core/lib/ssl.py:120 → ssl.wrap_socket()
3.Researched the Python 3.12 changelog and Stack Overflow to understand the removal:
- Deprecated since Python 3.7
- Fully removed in Python 3.12 due to CWE-295 (Improper Certificate Validation)
- Modern replacement:
ssl.SSLContext().wrap_socket()as previously mentioned by the contributors above.
-
While Searching existing issues i found related issue #1190 covering the same root cause.
-
Found PR #1177 which addresses both the main code and test mocks. Local test results after applying PR #1177's changes on WSL2 (Ubuntu 24.04, Python 3.12.3):
make test:- Before: 285 passed, 2 failed ❌
- After: 287 passed, 0 failed ✅
Conclusion:
PR #1177 fully resolves this issue. However, I noticed it currently has some failing CI checks that may need attention before it is ready to merge.
Could maintainers update PR #1177 to also reference
Fixes #1302 so this issue gets automatically closed
on merge?
Happy to participate. I Hope this resolves the issue.