ssl.create_default_context
Prev: ssl.create_connection | Up: ssl | Next: ssl.DefaultVerifyPaths
Rel: ssl.AlertDescription, ssl.cert_time_to_seconds, ssl.CertificateError, ssl.create_connection
Ref: docs.python.org — ssl.create_default_context
Tags: #public #python3 #stdlib #ssl
Import
import ssl
from ssl import create_default_context
Signature & Overview
ssl.create_default_context(purpose=<Purpose.SERVER_AUTH: _ASN1Object(nid=129, shortname='serverAuth', longname='TLS Web Server Authentication', oid='1.3.6.1.5.5.7.3.1')>, *, cafile=None, capath=None, cadata=None)
Create a SSLContext object with default settings.
Usage
import ssl
ctx = ssl.create_default_context()
assert ctx.check_hostname is True and ctx.verify_mode == ssl.CERT_REQUIRED
Gotchas
- Always start here for TLS: Loads system CA certificates, enables hostname verification, and selects secure modern TLS defaults automatically.
REPL Inspect
from ssl import create_default_context
help(create_default_context)
Linked from
Related notes
- tuts/python3/stdlib_module/ssl/AlertDescription Linked here; links to this page; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/cert_time_to_seconds Linked here; links to this page; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/CertificateError Linked here; links to this page; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/create_connection Linked here; links to this page; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/DefaultVerifyPaths Linked here; links to this page; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ssl/DER_cert_to_PEM_cert shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/get_default_verify_paths shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/get_protocol_name shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/get_server_certificate shared tags: #ssl, #stdlib