Skip to main content

pyopenssl-psk

Add PSK support to pyOpenSSL.

Installation

$ pip install pyopenssl-psk

API

Patch Method

  • patch_context()

    Add PSK related methods to the OpenSSL.SSL.Context class.

from openssl_psk import patch_context

patch_context()

Server Methods

  • Context.use_psk_identity_hint(hint: bytes) -> None

    Set the server PSK identity hint.

  • Context.set_psk_server_callback(callback: server_callback) -> None

    Set a callback to populate the server PSK.

    server_callback(connection: Connection, client_identity: bytes) -> psk: bytes

    User provided callback function to populate the connection PSK.

from OpenSSL.SSL import Context, Connection, TLSv1_2_METHOD

PSK_MAP = {
    b'pre_shared_key_identity': b'pre_shared_key',
}

def server_callback(conn, client_identity):
    return PSK_MAP[client_identity]

ctx = Context(TLSv1_2_METHOD)
ctx.set_cipher_list(b'PSK')
ctx.use_psk_identity_hint(b'pre_shared_key_identity_hint')
ctx.set_psk_server_callback(server_callback)
server = Connection(ctx)

Client Methods

  • Context.set_psk_client_callback(callback: client_callback) -> None

    Set a callback to populate the client PSK identity and PSK.

    client_callback(connection: Connection, identity_hint: bytes) -> tuple(psk_identity: bytes, psk: bytes)

    User provided callback function to populate the connection PSK identity and PSK.

from OpenSSL.SSL import Context, Connection, TLSv1_2_METHOD

def client_callback(conn, identity_hint):
    return (b'pre_shared_key_identity', b'pre_shared_key')

ctx = Context(TLSv1_2_METHOD)
ctx.set_cipher_list(b'PSK')
ctx.set_psk_client_callback(client_callback)
client = Connection(ctx)

See OpenSSL.SSL documentation for more information.

Metadata

Release files for pyopenssl-psk 1.0.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 pyopenssl-psk 1.0.0
File Size Uploaded
pyopenssl-psk-1.0.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyopenssl-psk 1.0.0
File Interpreter ABI Platform
pyopenssl_psk-1.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 15.0 kB

Release files / pyopenssl-psk-1.0.0.tar.gz

Download URL pyopenssl-psk-1.0.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
411bdf469d85f9f3009662196bd2d103a01e3d972dcd7680b89fc950fa8c9500
BLAKE2b-256 checksum
How to use checksums
b7b7d180474eee89b39a44f8622db8a800d3292458e990cd06ac31d602f6cf1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.8.0

Release files / pyopenssl_psk-1.0.0-py2.py3-none-any.whl

Download URL pyopenssl_psk-1.0.0-py2.py3-none-any.whl
Size 7.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
50672100e4ef0fa76860e6075eb274fead16296cde5895277e52517e8dea8843
BLAKE2b-256 checksum
How to use checksums
341b463a1815ae4915292152590cf8c6778f0071d6b1bacecdf30873150788e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.8.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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