{"library":"sslpsk-pmd3","title":"SSL-PSK for PyMobileDevice3","type":"library","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.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install sslpsk-pmd3"],"cli":null},"imports":["import sslpsk_pmd3\nssl_sock = sslpsk_pmd3.wrap_socket(...)"],"auth":{"required":false,"env_vars":[]},"links":{"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},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"1.0.3","pypi_latest":"1.0.3","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":80,"avg_install_s":1.7,"avg_import_s":0.03,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"sslpsk-pmd3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"20.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"sslpsk-pmd3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.7,"import_time_s":0.02,"mem_mb":1.4,"disk_size":"24M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"sslpsk-pmd3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"22.1M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"sslpsk-pmd3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.7,"import_time_s":0.04,"mem_mb":1.4,"disk_size":"26M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"sslpsk-pmd3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"14.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"sslpsk-pmd3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.5,"import_time_s":0.03,"mem_mb":1.1,"disk_size":"17M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"sslpsk-pmd3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"sslpsk-pmd3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"sslpsk-pmd3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"sslpsk-pmd3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.02,"mem_mb":1.4,"disk_size":"23M"}]}}