{"id":21605,"library":"nassl","title":"nassl","description":"Experimental OpenSSL wrapper for Python 3.10+ and SSLyze, providing low-level access to SSL/TLS internals including X.509 certificate extraction, OCSP stapling, and custom handshake logic. Current version 5.4.0, released approximately quarterly.","status":"active","version":"5.4.0","language":"python","source_language":"en","source_url":"https://github.com/nabla-c0d3/nassl","tags":["ssl","tls","openssl","security","certificate","wrapper"],"install":[{"cmd":"pip install nassl","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Top-level import is the correct API; submodule path changed in v5.","wrong":"from nassl.ssl_client import SslClient","symbol":"SslClient","correct":"from nassl import SslClient"},{"note":"Legacy path removed in v5; use top-level import.","wrong":"from nassl.legacy import SslConnection","symbol":"SslConnection","correct":"from nassl import SslConnection"},{"note":"","wrong":"","symbol":"CertificateInfo","correct":"from nassl import CertificateInfo"}],"quickstart":{"code":"from nassl import SslClient\n\nclient = SslClient('www.google.com', 443)\nclient.do_handshake()\nprint('Server cert CN:', client.get_certificate_info().subject.get('CN'))\nclient.close()","lang":"python","description":"Basic TLS handshake with Google and print Common Name."},"warnings":[{"fix":"Use Python 3.10+ or stay on nassl v4 if you must use older Python.","message":"nassl v5 dropped support for Python <3.10. Upgrade your Python environment.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"from nassl._nassl import OpenSSL_Error\ntry: ...\nexcept OpenSSL_Error: ...","message":"SslClient.do_handshake() raises a custom 'Connection error' on failure, not a built-in exception. Catch nassl._nassl.OpenSSL_Error.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace start_ssl_client with SslClient(); use get_certificate_info().","message":"Old API 'start_ssl_client' and 'get_certificate_chain' are deprecated and will be removed in v6. Use SslClient and SslClient.get_certificate_info().","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"if not client.is_closed(): client.do_handshake()","message":"Calling do_handshake() on an already-closed client raises RuntimeError. Always check if client.is_connected before reusing.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install nassl --upgrade && verify Python version with python --version (must be 3.10+).","cause":"Environment running Python <3.10 or nassl not installed.","error":"ModuleNotFoundError: No module named 'nassl'"},{"fix":"Use: from nassl import SslClient","cause":"Attempting import from wrong submodule; SslClient is now at top-level.","error":"ImportError: cannot import name 'SslClient' from 'nassl'"},{"fix":"Specify an SSL version: SslClient(host, port, ssl_version='TLSv1.3')","cause":"Server rejected TLS version or cipher. nassl defaults to TLS 1.2; some servers require TLS 1.3.","error":"nassl._nassl.OpenSSL_Error: ('ssl', 'tlsv1 alert internal error')"},{"fix":"Use client.get_certificate_info().certificate_chain instead.","cause":"Method deprecated in v4 and removed in v5.","error":"AttributeError: 'SslClient' object has no attribute 'get_certificate_chain'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}