Adds TLS-PSK support to the Python ssl package
Project description
sslpsk3
This module adds TLS-PSK support to the ssl package in Python 3.7+.
Installation
pip install sslpsk3
pip builds from source for Linux and Mac OSX, so a C compiler, the Python
development headers, and the OpenSSL development headers are required. For
Microsoft Windows, pre-built binaries are available so there are no such
prerequisites.
Usage
The old method of using ssl.wrap_socket(...) is deprecated and not available in Python 3.12+, so the recommended way
is SSLContext.
This library introduces a drop-in replacement SSLPSKContext class which supports TLS-PSK.
On Python 3.13 and newer, it uses the native implementation; on older versions, a custom implementation based on OpenSSL is used.
Server code example:
import ssl
from sslpsk3 import SSLPSKContext
context = SSLPSKContext(ssl.PROTOCOL_TLS_SERVER)
context.maximum_version = ssl.TLSVersion.TLSv1_2
context.set_ciphers("PSK")
context.set_psk_server_callback(lambda identity: b"abcdef", identity_hint="server_hint")
sock = context.wrap_socket(...)
Client code example:
import ssl
from sslpsk3 import SSLPSKContext
context = SSLPSKContext(ssl.PROTOCOL_TLS_CLIENT)
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
context.maximum_version = ssl.TLSVersion.TLSv1_2
context.set_ciphers("PSK")
context.set_psk_client_callback(lambda hint: ("client_identity", b"abcdef"))
sock = context.wrap_socket(...)
For more information refer
to the Python documentation as
well as the test_context_simple.py test file.
That being said, this library also still contains a backported version of wrap_context(), which works the same way as
in previous versions of sslpsk/sslpsk2/sslpsk3. If possible, please migrate to SSLPSKContext anyway.
Backstory
There were two published versions on PyPI, both without Python 3.11 support.
Additionally, for whatever reason, the Windows build of sslpsk2 for Python 3.10 has been linked against OpenSSL 3,
while Python 3.10 on Windows uses OpenSSL 1.1.1, which causes run-time crashes (Python started using OpenSSL 3 in
3.11.5).
This fork aims to fix the incompatibility between Python and OpenSSL versions.
Availability of binary wheels for Windows:
sslpsk |
sslpsk2 |
sslpsk3 |
|
|---|---|---|---|
| Python 2.7 | 1.0.0 | - | - |
| Python 3.3 | 1.0.0 | - | - |
| Python 3.4 | 1.0.0 | - | - |
| Python 3.5 | 1.0.0 | - | - |
| Python 3.6 | 1.0.0 | - | - |
| Python 3.7 | - | 1.0.1 | 2.0.0+ |
| Python 3.8 | - | 1.0.1 | 1.1.0+ |
| Python 3.9 | - | 1.0.1 | 1.1.0+ |
| Python 3.10 | - | 1.0.2 | 1.1.0+ |
| Python 3.11 | - | - | 1.1.0+ |
| Python 3.12 | - | - | 2.0.0+ |
| Python 3.13 | - | - | 2.0.0+ |
Changelog
- 0.1.0 (July 31, 2017)
- initial release
- 1.0.0 (August 2, 2017)
- include tests in pip distribution
- add support for Windows
- 1.0.1 (August 11, 2020)
- OpenSSL 1.1.1
- Fix with _sslobj
- Build from source in Windows with error description, when OpenSSL files are not present
- 1.1.0 (September 13, 2023)
- Migrate to GitHub actions
- Reformat code
- Support OpenSSL v1 and v3
- 2.0.0 (September 2, 2025)
- Rewrite library based on SSLContext
- Support Python 3.13 and later
- Add a new test suite
Acknowledgments
Fork of drbild/sslpsk.
The main approach was borrowed from webgravel/common-ssl.
Version from autinerd/sslpsk2 updated to work with OpenSSL v1 and v3.
Updates for SSLContext inspired by a PR created by @doronz88.
Contributing
Please submit bugs, questions, suggestions, or (ideally) contributions as issues and pull requests on GitHub.
License
Copyright 2017 David R. Bild, 2020 Sidney Kuyateh, 2025 Kuba Szczodrzyński
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License from the LICENSE.txt file or at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sslpsk3-2.0.0.tar.gz.
File metadata
- Download URL: sslpsk3-2.0.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61990f549d30744631bc8e7977f0765729ac808efcefa180c08d260b7049be11
|
|
| MD5 |
88d865637f61afc5db71f24e3966ab4a
|
|
| BLAKE2b-256 |
c86510f6b981bca7750d2e6597a335c2a8357d63b0a39bbf79f777c6dbdda656
|
File details
Details for the file sslpsk3-2.0.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: sslpsk3-2.0.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 24.1 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aac594cdfcdf32dd6eeaac50144e49766c17140debcf07deaaa9e0cc337aca38
|
|
| MD5 |
8ac7d337344a4cc980bbf2f7ffa71b08
|
|
| BLAKE2b-256 |
109580a1b81a5a1655c9971da6fe29aeaccbdb8a2f8992db89958f32eb4d453e
|
File details
Details for the file sslpsk3-2.0.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: sslpsk3-2.0.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 24.1 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80ae5bce141fe6f860f00622a87257914fa603208dd0f54f4c8e14a3b3424bbd
|
|
| MD5 |
21028d79a7ef65432e8a8ae5076a247c
|
|
| BLAKE2b-256 |
f95e861ba6d7d3318c32e88a4e4c5b53781f241fe05eeb92751b84eb9ff57a39
|
File details
Details for the file sslpsk3-2.0.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: sslpsk3-2.0.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 24.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7773b65ee746bee7f4b1b090dcf501c97b9ab69fbccdad2a84626bfc783feca
|
|
| MD5 |
a5445bf357ec7f5059c27abaa28f4c6d
|
|
| BLAKE2b-256 |
d0b21ac70cf17d7aa5308895375ad150ea654dba5514bd7f7381454f06d15b0f
|
File details
Details for the file sslpsk3-2.0.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: sslpsk3-2.0.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 24.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ed380bc46cf3d8e99b9fc6453b4fb702dbf0193de01730950b6508704e849b7
|
|
| MD5 |
52385e31a55a212be1aeea9c5430adbd
|
|
| BLAKE2b-256 |
cead0a3374755e2219b3a04dd9abe60fdc7ed4a19cecc7f2c3c7511d92771cb2
|
File details
Details for the file sslpsk3-2.0.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: sslpsk3-2.0.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 24.0 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a7970be2348e676dd3ee4c72215cb2a94f07b40f5df650aa2d738f6f8c7efd9
|
|
| MD5 |
6bb81072147042d9406c9de43d462249
|
|
| BLAKE2b-256 |
dc4d62408aac89026a04f8651aad3ed4e367cff67723755c522b44e3dfa1f6ae
|
File details
Details for the file sslpsk3-2.0.0-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: sslpsk3-2.0.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 24.0 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d1138c2cee57566bf05ff14eebb78e204f1288af0f65b5fa9cacbfe55a5674e
|
|
| MD5 |
b3c7ab8ea4b4cecbdd2027861efc7969
|
|
| BLAKE2b-256 |
f7728c49b3bc16dbcb6b3fa4f5b2cc1e7dbdba5a238bbdff99eca2738809a1ac
|
File details
Details for the file sslpsk3-2.0.0-cp37-cp37m-win_amd64.whl.
File metadata
- Download URL: sslpsk3-2.0.0-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 23.5 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
513d626b5369755e45f5f41581fd08cf5b34a60cc28a97a689de39ed1629a8da
|
|
| MD5 |
eb52d5b05658e0114df09a80de56590f
|
|
| BLAKE2b-256 |
cf008fac4bdcf711a80e63765dbf74d436fdee2d12bd4e70ea7d5181af3767e3
|