Skip to main content

sslpsk3

PyPI version

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.

Building for Windows

The binary Windows module can be built using FireDaemon OpenSSL Binary Distributions.

OpenSSL 1.x.x and 3.x.x libraries must be extracted to openssl1-win32/64 and openssl3-win32/64 folders respectively. The resulting folder structure should look as follows:

openssl#-win##/
    include/openssl/
        <headers>
    lib/
        libcrypto.lib
        libssl.lib
  1. To build and install the library, use pip install -e . (editable mode).
  2. To build a binary wheel distribution, use poetry build --format=wheel.

In both cases, the resulting PYD (DLL) must be patched using python sslpsk3_fixup.py. This makes sure the libssl3.dll reference is not erroneously using the -x64 suffix.

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+
Python 3.14 - - 2.1.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
  • 2.1.0 (March 27, 2026)
    • Build for 32-bit Windows
    • Use OpenSSL from FireDaemon

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.

Metadata

Release files for sslpsk3 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sslpsk3 2.1.0
File Size Uploaded Provenance
sslpsk3-2.1.0.tar.gz 11.8 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for sslpsk3 2.1.0
File
sslpsk3-2.1.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
sslpsk3-2.1.0-cp314-cp314-win32.whl CPython 3.14 CPython 3.14 Windows x86-32 Details
sslpsk3-2.1.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
sslpsk3-2.1.0-cp313-cp313-win32.whl CPython 3.13 CPython 3.13 Windows x86-32 Details
sslpsk3-2.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
sslpsk3-2.1.0-cp312-cp312-win32.whl CPython 3.12 CPython 3.12 Windows x86-32 Details
sslpsk3-2.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
sslpsk3-2.1.0-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details
sslpsk3-2.1.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
sslpsk3-2.1.0-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details
sslpsk3-2.1.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
sslpsk3-2.1.0-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details
sslpsk3-2.1.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
sslpsk3-2.1.0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
sslpsk3-2.1.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
sslpsk3-2.1.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details

Total release size: 397.7 kB

Release files / sslpsk3-2.1.0.tar.gz

Download URL sslpsk3-2.1.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ac06ad206f1a503da63d50528d4e47cb9c01f52dc90ffccc6326d0e5f55692eb
BLAKE2b-256 checksum
How to use checksums
6cf32c353fe0a46d2d5a89c44f125cc656863d86e485cf36ece3891b2125dc83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp314-cp314-win_amd64.whl

Download URL sslpsk3-2.1.0-cp314-cp314-win_amd64.whl
Size 25.1 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
f248f716a2e7b532b778a265547a2e0e92e1f584fb3d4b3c772eac57381bdbdc
BLAKE2b-256 checksum
How to use checksums
8fe3e7cc405f0ee535430f2465dda86ba05facc6684621a311c38bc3d1131b3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp314-cp314-win32.whl

Download URL sslpsk3-2.1.0-cp314-cp314-win32.whl
Size 24.1 kB
Tags CPython 3.14 Windows x86-32
SHA-256 checksum
How to use checksums
082824177f3a6c041475744baade5ffcad2e18d90ac53c7a677debb9a7981116
BLAKE2b-256 checksum
How to use checksums
f9ec8b773cc07b439de85d420d81f5f0bd6884b269529717edcda8063801ce0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp313-cp313-win_amd64.whl

Download URL sslpsk3-2.1.0-cp313-cp313-win_amd64.whl
Size 24.7 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
6cc31b9bc56362e16f399130d430b8ae91949bf165bdab1900aa4bf15d1098a4
BLAKE2b-256 checksum
How to use checksums
ac76134f44c0957b7175df80d4c8f2bb59c9e7b015bb96d643faece7f52f0783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp313-cp313-win32.whl

Download URL sslpsk3-2.1.0-cp313-cp313-win32.whl
Size 23.7 kB
Tags CPython 3.13 Windows x86-32
SHA-256 checksum
How to use checksums
a36be39d218343bc43cfe0c129ac98a7f2b6af42009213135e299a55b2f2ba2a
BLAKE2b-256 checksum
How to use checksums
edc4f0c2e5af647625fec9f4943ca163474f37bf297b60a607194fff90909208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp312-cp312-win_amd64.whl

Download URL sslpsk3-2.1.0-cp312-cp312-win_amd64.whl
Size 24.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
17a4b4d56d11572640ff7c651f18c741bf0f09defed738204dc390a7698dbf00
BLAKE2b-256 checksum
How to use checksums
c0769170067f32d719a8359f7acf45d410e0f55cdf0cb63c56ff39b443ee401a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp312-cp312-win32.whl

Download URL sslpsk3-2.1.0-cp312-cp312-win32.whl
Size 23.7 kB
Tags CPython 3.12 Windows x86-32
SHA-256 checksum
How to use checksums
c31575d7274e16e712bb9cce868acde47f6de90b0f2fc8f5ae0fd5475753860d
BLAKE2b-256 checksum
How to use checksums
596f753886714ec9c214367a02abeca377aefe26dde9410119f8632a1672cec4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp311-cp311-win_amd64.whl

Download URL sslpsk3-2.1.0-cp311-cp311-win_amd64.whl
Size 24.6 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
150bd2da479146650b1a382f73ce69c34ac9fe529bd963fcdcba56ef2f6241a9
BLAKE2b-256 checksum
How to use checksums
e0f2b12dfaab095c9be3e89ec65521f8ba503d6519e8cb33d3a16925e3a16584
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp311-cp311-win32.whl

Download URL sslpsk3-2.1.0-cp311-cp311-win32.whl
Size 23.7 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
6d510b69236a22a5ded23f44d98501d3a853e3b8c2b9a7ccd9bfec36ffc2a8ac
BLAKE2b-256 checksum
How to use checksums
e1b199a089eb32b3cbf7dde4bbf044471e84d41510e0be856c4026d11e6aae11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp310-cp310-win_amd64.whl

Download URL sslpsk3-2.1.0-cp310-cp310-win_amd64.whl
Size 24.6 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
9dbe128765c56d54bb6d136f0a4f23eccc8edb2f4f25dd08b4e6fc52ee52a9fb
BLAKE2b-256 checksum
How to use checksums
9290ad27cb7ffe0fbf6c53f044e5cb368d0b9d566720bf8bcb891ae83f5a65ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp310-cp310-win32.whl

Download URL sslpsk3-2.1.0-cp310-cp310-win32.whl
Size 23.7 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
cedc2be9e9b5f96bd638c731bbd13c03fbaf71d1ca4cad163e69a089e1f098bf
BLAKE2b-256 checksum
How to use checksums
0e5434a768c7637b486010fadaf85dce0e3fa8c9056e396a60747d2fa4d63678
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp39-cp39-win_amd64.whl

Download URL sslpsk3-2.1.0-cp39-cp39-win_amd64.whl
Size 24.6 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
085c7a06322bc2801432c1ea89e8aad4630c55b3fce7fbfbfe06b00fe568d3cd
BLAKE2b-256 checksum
How to use checksums
13f143a00587d818ebce4a91da6bb483bfce9d1e540b203308a500d53933c73f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp39-cp39-win32.whl

Download URL sslpsk3-2.1.0-cp39-cp39-win32.whl
Size 23.7 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
4938d8c6bcf00f72aaa0ced989f7a50de3edc4b53f987dd9828725101d9c6169
BLAKE2b-256 checksum
How to use checksums
da9a91dee10c42d6fcda8e777938b2a6ba5e3d88e39a85e2f92b6d3f8d05f394
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp38-cp38-win_amd64.whl

Download URL sslpsk3-2.1.0-cp38-cp38-win_amd64.whl
Size 24.4 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
833d60459fba2e34f8437a871cf86d4afe85c46d99155c2c7c4687c974b9fe04
BLAKE2b-256 checksum
How to use checksums
ffab29527f16294d18278dc424828028205b19bfadd768413a687f4dc286c5b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp38-cp38-win32.whl

Download URL sslpsk3-2.1.0-cp38-cp38-win32.whl
Size 23.5 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
d8bbbb6e5e8a9eec0ba8be494392f49c94a2f0fe425a59c66839f7949f978e16
BLAKE2b-256 checksum
How to use checksums
a1d50a0a1d497602b19f73b5b05b64dde52ad2ecba01590ee99921605281583a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp37-cp37m-win_amd64.whl

Download URL sslpsk3-2.1.0-cp37-cp37m-win_amd64.whl
Size 23.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
df51dcab59afb18d9b6be7c34742ab15c527c07a60aacbe9478285f3d1e79363
BLAKE2b-256 checksum
How to use checksums
596cc64979b9870f0716debd608e16944750f00be6aa0f8e3baafa154f8aaeda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / sslpsk3-2.1.0-cp37-cp37m-win32.whl

Download URL sslpsk3-2.1.0-cp37-cp37m-win32.whl
Size 22.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
84983d3d9c36077b49b7d71b30cc4430367b811f51378862d4893580817ed51d
BLAKE2b-256 checksum
How to use checksums
fd40366cfb03816442754e0079466d9edb76f48313e9bb19d7b2d646ea32b3f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Security for sslpsk3 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page