{"id":8683,"library":"sslpsk-pmd3","title":"SSL-PSK for PyMobileDevice3","description":"sslpsk-pmd3 is a fork of the `sslpsk` library, specifically tailored to add TLS-PSK (Pre-Shared Key) support to the Python `ssl` package for `pymobiledevice3` usage. It enables secure socket communication using pre-shared keys, an alternative to traditional certificate-based TLS. The current version is 1.0.3, released on February 9, 2024, with irregular but active maintenance.","status":"active","version":"1.0.3","language":"python","source_language":"en","source_url":"https://github.com/doronz88/sslpsk-pmd3","tags":["ssl","tls","psk","tls-psk","preshared key","pymobiledevice3"],"install":[{"cmd":"pip install sslpsk-pmd3","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for underlying TLS-PSK functionality, specifically development headers for source builds.","package":"OpenSSL","optional":false}],"imports":[{"wrong":"import sslpsk_pmd3","symbol":"wrap_socket","correct":"from sslpsk_pmd3 import wrap_socket"},{"wrong":"import sslpsk_pmd3","symbol":"SSLPSKContext","correct":"from sslpsk_pmd3 import SSLPSKContext"},{"wrong":"import sslpsk_pmd3","symbol":"sslpsk","correct":"from sslpsk_pmd3 import sslpsk"}],"quickstart":{"code":"import socket\nimport sslpsk_pmd3\nimport os\n\n# Configuration from environment variables for security and flexibility\nHOST = os.environ.get('PSK_HOST', '127.0.0.1')\nPORT = int(os.environ.get('PSK_PORT', 6000))\nPSK_KEY = os.environ.get('PSK_KEY', 'abcdef').encode('utf-8')\nCLIENT_IDENTITY = os.environ.get('PSK_IDENTITY', 'client1').encode('utf-8')\n\ndef client_example(host, port, psk_key, client_identity):\n    try:\n        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n        print(f\"Attempting to connect to {host}:{port}...\")\n        sock.connect((host, port))\n        print(\"Socket connected. Wrapping with TLS-PSK...\")\n        \n        # Wrap the socket with TLS-PSK support\n        # PROTOCOL_TLSv1_2 is a common, widely supported version.\n        ssl_sock = sslpsk_pmd3.wrap_socket(\n            sock,\n            psk=psk_key,\n            psk_identity=client_identity,\n            ssl_version=sslpsk_pmd3.PROTOCOL_TLSv1_2\n        )\n        print(\"SSL socket wrapped. Sending data...\")\n        \n        message = \"Hello, TLS-PSK Server!\\n\"\n        ssl_sock.sendall(message.encode())\n        print(f\"Client sent: {message.strip()}\")\n        \n        received_data = ssl_sock.recv(1024).decode().strip()\n        print(f\"Client received: {received_data}\")\n        \n    except ConnectionRefusedError:\n        print(f\"Error: Connection refused. Ensure a TLS-PSK server is running on {host}:{port}.\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n    finally:\n        if 'ssl_sock' in locals() and ssl_sock:\n            ssl_sock.shutdown(socket.SHUT_RDWR)\n            ssl_sock.close()\n        elif 'sock' in locals() and sock:\n            sock.close()\n        print(\"Connection closed.\")\n\nif __name__ == '__main__':\n    print(\"This quickstart demonstrates client-side usage of sslpsk-pmd3.\")\n    print(\"A corresponding TLS-PSK server is required to fully execute this example.\")\n    print(\"You can configure host, port, key, and identity via PSK_HOST, PSK_PORT, PSK_KEY, PSK_IDENTITY environment variables.\")\n    print(f\"Using defaults: Host={HOST}, Port={PORT}, PSK_KEY={'*' * len(PSK_KEY)}, PSK_IDENTITY={CLIENT_IDENTITY.decode()}\")\n    client_example(HOST, PORT, PSK_KEY, CLIENT_IDENTITY)","lang":"python","description":"This client-side example demonstrates how to establish a TLS-PSK connection using `sslpsk_pmd3.wrap_socket`. It connects to a specified host and port, wraps the socket with a pre-shared key and client identity, sends a message, and receives a response. Ensure a compatible TLS-PSK server is running for this example to fully succeed. Environment variables are used for sensitive information like PSK and connection details."},"warnings":[{"fix":"Use Python 3.8 to 3.12. Monitor GitHub for future 3.13+ support.","message":"Python 3.13 is not officially supported by sslpsk-pmd3. Attempts to install on Python 3.13 may lead to build failures.","severity":"breaking","affected_versions":"All versions on Python 3.13+"},{"fix":"Ensure OpenSSL development headers are installed (e.g., `sudo apt-get install libssl-dev` on Debian/Ubuntu, `brew install openssl@1.1` or `openssl@3` and linking on macOS).","message":"Installing sslpsk-pmd3 from source may fail if OpenSSL development headers are not installed on your system, particularly on macOS or Linux.","severity":"gotcha","affected_versions":"All versions, when building from source"},{"fix":"For `sslpsk-pmd3`, continue using `sslpsk_pmd3.wrap_socket`. For general Python SSL usage, prefer `ssl.create_default_context().wrap_socket()` or similar `SSLContext`-based approaches.","message":"The `ssl.wrap_socket()` function, which `sslpsk-pmd3`'s primary API emulates, is considered deprecated in upstream Python's `ssl` module since Python 3.2 (and 2.7.9) in favor of `SSLContext.wrap_socket()`. While `sslpsk-pmd3` still uses the `wrap_socket` pattern, for future compatibility and advanced features (like SNI), users of the underlying `sslpsk` might consider migrating to `SSLPSKContext` if available or planning for its adoption.","severity":"deprecated","affected_versions":"All versions of sslpsk-pmd3 on Python 3.12+"}],"env_vars":null,"search_vec":"'1.0.3':58 '2024':63 '9':62 'activ':67 'add':19 'altern':47 'base':52 'certif':51 'certificate-bas':50 'communic':40 'current':55 'enabl':37 'februari':61 'fork':11 'irregular':65 'key':26,45,76 'librari':15 'mainten':68 'packag':32 'pmd3':8 'pre':24,43 'pre-shar':23,42 'preshar':75 'psk':3,22,71,74 'pymobiledevice3':5,34,77 'python':30 'releas':59 'secur':38 'share':25,44 'socket':39 'specif':16 'ssl':2,31,69 'ssl-psk':1 'sslpsk':7,14 'sslpsk-pmd3':6 'support':27 'tailor':17 'tls':21,53,70,73 'tls-psk':20,72 'tradit':49 'usag':35 'use':41 'version':56","created_at":"2026-04-16T17:03:27.944459+00:00","updated_at":"2026-04-16T17:03:27.944459+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.0.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/doronz88/sslpsk-pmd3","docs":null,"changelog":null,"pypi":"https://pypi.org/project/sslpsk-pmd3/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}