ssl.SSLContext()
ssl.SSLContext() is a Python function in the SSL Module category. Creates an SSL context for configuring SSL/TLS connections. The syntax is ssl.SSLContext(protocol=ssl.PROTOCOL_TLS). Returns: SSLContext object. A typical example: ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ctx.load_verify_locations("cert.pem")
ctx.check_hostname = True. A close sibling is ssl.wrap_socket(), which wraps an existing socket for SSL/TLS encryption. A close sibling is ssl.create_default_context(), which creates a default SSL/TLS context with reasonable security settings. A close sibling is ssl.get_server_certificate(), which fetches the SSL certificate from a server and returns it as PEM string. More about this category: SSL/TLS wrapper — wrap_socket, get_server_certificate, create_default_context. Related SSL Module entries: ssl.wrap_socket(), ssl.create_default_context(), ssl.get_server_certificate(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try ssl.SSLContext() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.