Lines Matching +full:enable +full:- +full:weak +full:- +full:ssl +full:- +full:ciphers
1 :mod:`ssl` --- TLS/SSL wrapper for socket objects
4 .. module:: ssl
5 :synopsis: TLS/SSL wrapper for socket objects
10 **Source code:** :source:`Lib/ssl.py`
12 .. index:: single: OpenSSL; (use in module ssl)
14 .. index:: TLS, SSL, Transport Layer Security, Secure Sockets Layer
16 --------------
20 sockets, both client-side and server-side. This module uses the OpenSSL
32 Don't use this module without reading the :ref:`ssl-security`. Doing so
34 ssl module are not necessarily appropriate for your application.
37 This section documents the objects and functions in the ``ssl`` module; for more
38 general information about TLS, SSL, and certificates, the reader is referred to
41 This module provides a class, :class:`ssl.SSLSocket`, which is derived from the
42 :class:`socket.socket` type, and provides a socket-like wrapper that also
43 encrypts and decrypts the data going over the socket with SSL. It supports
48 For more sophisticated applications, the :class:`ssl.SSLContext` class
50 by SSL sockets created through the :meth:`SSLContext.wrap_socket` method.
58 In the future the ssl module will require at least OpenSSL 1.0.2 or
63 :pep:`644` has been implemented. The ssl module requires OpenSSL 1.1.1
70 ------------------------------------
87 import ssl
90 context = ssl.create_default_context()
101 context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
111 context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
131 the given *purpose*. The settings are chosen by the :mod:`ssl` module,
169 use this function but still allow SSL 3.0 connections you can re-enable
172 ctx = ssl.create_default_context(Purpose.CLIENT_AUTH)
173 ctx.options &= ~ssl.OP_NO_SSLv3
203 Raised to signal an error from the underlying SSL implementation
205 problem in the higher-level encryption and authentication layer that's
216 occurred, such as ``SSL``, ``PEM`` or ``X509``. The range of possible
232 the SSL connection has been closed cleanly. Note that this doesn't
239 A subclass of :exc:`SSLError` raised by a :ref:`non-blocking SSL socket
240 <ssl-nonblocking>` when trying to read or write data, but more data needs
248 A subclass of :exc:`SSLError` raised by a :ref:`non-blocking SSL socket
249 <ssl-nonblocking>` when trying to read or write data, but more data needs
258 while trying to fulfill an operation on a SSL socket. Unfortunately,
265 A subclass of :exc:`SSLError` raised when the SSL connection has been
299 Return *num* cryptographically strong pseudo-random bytes. Raises an
316 Return (bytes, is_cryptographic): bytes are *num* pseudo-random bytes,
321 Generated pseudo-random byte sequences will be unique if they are of
323 for non-cryptographic purposes and for certain purposes in cryptographic
332 OpenSSL has deprecated :func:`ssl.RAND_pseudo_bytes`, use
333 :func:`ssl.RAND_bytes` instead.
337 Return ``True`` if the SSL pseudo-random number generator has been seeded
339 :func:`ssl.RAND_egd` and :func:`ssl.RAND_add` to increase the randomness of
340 the pseudo-random number generator.
344 Mix the given *bytes* into the SSL pseudo-random number generator. The
350 Writable :term:`bytes-like object` is now accepted.
357 import ssl
366 various SSL-based protocols such as FTPS, IMAPS, POPS and others.
372 >>> ssl.match_hostname(cert, "example.com")
373 >>> ssl.match_hostname(cert, "example.org")
376 File "/home/py3k/Lib/ssl.py", line 130, in match_hostname
377 ssl.CertificateError: hostname 'example.org' doesn't match 'example.com'
385 IDN A-labels such as ``www*.xn--pthon-kva.org`` are still supported,
386 but ``x*.python.org`` no longer matches ``xn--tda.python.org``.
413 >>> import ssl
414 >>> timestamp = ssl.cert_time_to_seconds("Jan 5 09:34:43 2018 GMT")
419 2018-01-05 09:34:43
432 Given the address ``addr`` of an SSL-protected server, as a (*hostname*,
433 *port-number*) pair, fetches the server's certificate, and returns it as a
434 PEM-encoded string. If ``ssl_version`` is specified, uses that version of
435 the SSL protocol to attempt to connect to the server. If ``ca_certs`` is
444 This function is now IPv6-compatible.
455 Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded
460 Given a certificate as an ASCII PEM string, returns a DER-encoded sequence of
470 * :attr:`cafile` - resolved path to cafile or ``None`` if the file doesn't exist,
471 * :attr:`capath` - resolved path to capath or ``None`` if the directory doesn't exist,
472 * :attr:`openssl_cafile_env` - OpenSSL's environment key that points to a cafile,
473 * :attr:`openssl_cafile` - hard coded path to a cafile,
474 * :attr:`openssl_capath_env` - OpenSSL's environment key that points to a capath,
475 * :attr:`openssl_capath` - hard coded path to a capath directory
497 >>> ssl.enum_certificates("CA")
523 suppress_ragged_eofs=True, ciphers=None)
526 of :class:`ssl.SSLSocket`, a subtype of :class:`socket.socket`, which wraps
527 the underlying socket in an SSL context. ``sock`` must be a
532 parameters *keyfile*, *certfile*, *ca_certs* or *ciphers* are set, then
545 top-level function is limited and creates an insecure client socket
559 it is the default mode. With client-side sockets, just about any
561 are ignored and do not abort the TLS/SSL handshake.
566 See the discussion of :ref:`ssl-security` below.
573 use :const:`CERT_REQUIRED` for client-side sockets instead.
661 accept intermediate CAs in the trust store to be treated as trust-anchors,
662 in the same way as the self-signed root CA certificates. This makes it
678 Despite the name, this option can select both "SSL" and "TLS" protocols.
690 Auto-negotiate the highest protocol version that both the client and
691 server support, and configure the context client-side connections. The
699 Auto-negotiate the highest protocol version that both the client and
700 server support, and configure the context server-side connections.
714 Selects SSL version 2 as the channel encryption protocol.
721 SSL version 2 is insecure. Its use is highly discouraged.
729 Selects SSL version 3 as the channel encryption protocol.
736 SSL version 3 is insecure. Its use is highly discouraged.
778 Enables workarounds for various bugs present in other SSL implementations.
875 Prevents re-use of the same DH key for distinct SSL sessions. This
883 Prevents re-use of the same ECDH key for distinct SSL sessions. This
900 Disable compression on the SSL channel. This is useful if the application
925 Whether the OpenSSL library has built-in support for the *Application-Layer
932 Whether the OpenSSL library has built-in support not checking subject
940 Whether the OpenSSL library has built-in support for the Elliptic Curve-based
941 Diffie-Hellman key exchange. This should be true unless the feature was
948 Whether the OpenSSL library has built-in support for the *Server Name
955 Whether the OpenSSL library has built-in support for the *Next Protocol
957 Negotiation <https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation>`_.
965 Whether the OpenSSL library has built-in support for the SSL 2.0 protocol.
971 Whether the OpenSSL library has built-in support for the SSL 3.0 protocol.
977 Whether the OpenSSL library has built-in support for the TLS 1.0 protocol.
983 Whether the OpenSSL library has built-in support for the TLS 1.1 protocol.
989 Whether the OpenSSL library has built-in support for the TLS 1.2 protocol.
995 Whether the OpenSSL library has built-in support for the TLS 1.3 protocol.
1010 >>> ssl.OPENSSL_VERSION
1020 >>> ssl.OPENSSL_VERSION_INFO
1029 >>> ssl.OPENSSL_VERSION_NUMBER
1031 >>> hex(ssl.OPENSSL_VERSION_NUMBER)
1041 <https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-6>`_
1060 be used to create client-side sockets).
1069 be used to create server-side sockets).
1081 :class:`enum.IntEnum` collection of SSL and TLS versions for
1089 The minimum or maximum supported SSL or TLS version. These are magic
1091 TLS/SSL versions.
1099 SSL 3.0 to TLS 1.3.
1107 SSL Sockets
1108 -----------
1112 SSL sockets provide the following methods of :ref:`socket-objects`:
1114 - :meth:`~socket.socket.accept()`
1115 - :meth:`~socket.socket.bind()`
1116 - :meth:`~socket.socket.close()`
1117 - :meth:`~socket.socket.connect()`
1118 - :meth:`~socket.socket.detach()`
1119 - :meth:`~socket.socket.fileno()`
1120 - :meth:`~socket.socket.getpeername()`, :meth:`~socket.socket.getsockname()`
1121 - :meth:`~socket.socket.getsockopt()`, :meth:`~socket.socket.setsockopt()`
1122 - :meth:`~socket.socket.gettimeout()`, :meth:`~socket.socket.settimeout()`,
1124 - :meth:`~socket.socket.listen()`
1125 - :meth:`~socket.socket.makefile()`
1126 - :meth:`~socket.socket.recv()`, :meth:`~socket.socket.recv_into()`
1127 (but passing a non-zero ``flags`` argument is not allowed)
1128 - :meth:`~socket.socket.send()`, :meth:`~socket.socket.sendall()` (with
1130 - :meth:`~socket.socket.sendfile()` (but :mod:`os.sendfile` will be used
1131 for plain-text sockets only, else :meth:`~socket.socket.send()` will be used)
1132 - :meth:`~socket.socket.shutdown()`
1134 However, since the SSL (and TLS) protocol has its own framing atop
1135 of TCP, the SSL sockets abstraction can, in certain respects, diverge from
1136 the specification of normal, OS-level sockets. See especially the
1137 :ref:`notes on non-blocking sockets <ssl-nonblocking>`.
1163 zero-length data no longer fails with a protocol violation error.
1165 SSL sockets also have the following additional methods and attributes:
1169 Read up to *len* bytes of data from the SSL socket and return the result as
1174 :ref:`non-blocking <ssl-nonblocking>` and the read would block.
1176 As at any time a re-negotiation is possible, a call to :meth:`read` can also
1189 Write *buf* to the SSL socket and return the number of bytes written. The
1193 :ref:`non-blocking <ssl-nonblocking>` and the write would block.
1195 As at any time a re-negotiation is possible, a call to :meth:`write` can
1208 low-level methods that read and write unencrypted, application-level data
1209 and decrypt/encrypt it to encrypted, wire-level data. These methods
1210 require an active SSL connection, i.e. the handshake was completed and
1219 Perform the SSL setup handshake.
1239 return ``None``. If the SSL handshake hasn't been done yet, raise
1254 name-value pairs. Here is a real-world example::
1265 'subject': ((('description', '571208-SLe257oHY9fVQ07Z'),),
1281 provided, this method returns the DER-encoded form of the entire certificate
1283 certificate. Whether the peer provides a certificate depends on the SSL
1286 * for a client SSL socket, the server will always provide a certificate,
1289 * for a server SSL socket, the client will only provide a certificate
1308 Returns a three-value tuple containing the name of the cipher being used, the
1309 version of the SSL protocol that defines its use, and the number of secret
1314 Return the list of ciphers shared by the client during the handshake. Each
1315 entry of the returned list is a three-value tuple containing the name of the
1316 cipher, the version of the SSL protocol that defines its use, and the number
1328 If the higher-level protocol supports its own compression mechanism,
1329 you can use :data:`OP_NO_COMPRESSION` to disable SSL-level compression.
1333 .. method:: SSLSocket.get_channel_binding(cb_type="tls-unique")
1340 :data:`CHANNEL_BINDING_TYPES` list. Currently only the 'tls-unique' channel
1358 Return the higher-level protocol that was selected during the TLS/SSL
1371 Performs the SSL shutdown handshake, which removes the TLS layer from the
1379 Requests post-handshake authentication (PHA) from a TLS 1.3 client. PHA
1380 can only be initiated for a TLS 1.3 connection from a server-side socket,
1384 The method does not perform a cert exchange immediately. The server-side
1399 Return the actual SSL protocol version negotiated by the connection
1414 The :class:`SSLContext` object this SSL socket is tied to. If the SSL
1417 object created for this SSL socket.
1423 A boolean which is ``True`` for server-side sockets and ``False`` for
1424 client-side sockets.
1430 Hostname of the server: :class:`str` type, or ``None`` for server-side
1438 A-label form (``"xn--pythn-mua.org"``), rather than the U-label form
1443 The :class:`SSLSession` for this SSL connection. The session is available
1455 SSL Contexts
1456 ------------
1460 An SSL context holds various data longer-lived than single SSL connections,
1461 such as SSL configuration options, certificate(s) and private key(s).
1462 It also manages a cache of SSL sessions for server-side sockets, in order
1467 Create a new SSL context. You may pass *protocol* which must be one
1469 specifies which version of the SSL protocol to use. Typically, the
1483 …------------------------ ------------ ------------ ------------- --------- ----------- -----…
1500 :func:`create_default_context` lets the :mod:`ssl` module choose
1511 ciphers, no ``NULL`` ciphers and no ``MD5`` ciphers (except for
1523 ciphers with forward secrecy and security level 2. RSA and DH keys with
1553 :ref:`ssl-certificates` for more information on how the certificate
1560 a string it will be encoded as UTF-8 before using it to decrypt the key.
1566 OpenSSL's built-in password prompting mechanism will be used to
1603 :ref:`ssl-certificates` for more information about how to arrange the
1612 PEM-encoded certificates or a :term:`bytes-like object` of DER-encoded
1613 certificates. Like with *capath* extra lines around PEM-encoded
1624 the method returns a list of DER-encoded certificates. The returned list
1626 requested and loaded by a SSL connection.
1636 Get a list of enabled ciphers. The list is in order of cipher priority.
1641 >>> ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
1646 'auth': 'auth-rsa',
1647 'description': 'ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA '
1651 'kea': 'kx-ecdhe',
1652 'name': 'ECDHE-RSA-AES256-GCM-SHA384',
1655 'symmetric': 'aes-256-gcm'},
1658 'auth': 'auth-rsa',
1659 'description': 'ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 Kx=ECDH Au=RSA '
1663 'kea': 'kx-ecdhe',
1664 'name': 'ECDHE-RSA-AES128-GCM-SHA256',
1667 'symmetric': 'aes-128-gcm'}]
1680 .. method:: SSLContext.set_ciphers(ciphers)
1682 Set the available ciphers for sockets created with this context.
1684 <https://www.openssl.org/docs/manmaster/man1/ciphers.html>`_.
1685 If no cipher can be selected (because compile-time options or other
1686 configuration forbids use of all the specified ciphers), an
1690 when connected, the :meth:`SSLSocket.cipher` method of SSL sockets will
1698 Specify which protocols the socket should advertise during the SSL/TLS
1703 return the agreed-upon protocol.
1712 Specify which protocols the socket should advertise during the SSL/TLS
1716 <https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation>`_. After a
1718 return the agreed-upon protocol.
1732 handshake message has been received by the SSL/TLS server when the TLS client
1734 is specified in :rfc:`6066` section 3 - Server Name Indication.
1741 arguments; the first being the :class:`ssl.SSLSocket`, the second is a string
1746 name is an IDN A-label (``"xn--pythn-mua.org"``).
1748 A typical use of this callback is to change the :class:`ssl.SSLSocket`'s
1781 IDN-encoded internationalized domain name, the *server_name_callback*
1782 receives a decoded U-label (``"pythön.org"``).
1792 Load the key generation parameters for Diffie-Hellman (DH) key exchange.
1805 Set the curve name for Elliptic Curve-based Diffie-Hellman (ECDH) key
1808 a well-known elliptic curve, for example ``prime256v1`` for a widely
1819 …`SSL/TLS & Perfect Forward Secrecy <https://vincent.bernat.im/en/blog/2011-ssl-perfect-forward-sec…
1828 returned SSL socket is tied to the context, its settings and certificates.
1833 server-side or client-side behavior is desired from this socket.
1835 For client-side sockets, the context construction is lazy; if the
1838 server-side sockets, if the socket has no remote peer, it is assumed
1839 to be a listening socket, and the server-side SSL wrapping is
1845 single server to host multiple SSL-based services with distinct certificates,
1849 The parameter ``do_handshake_on_connect`` specifies whether to do the SSL
1874 instead of hard-coded :class:`SSLSocket`.
1888 :attr:`SSLContext.sslobject_class` (default :class:`SSLObject`). The SSL
1900 instead of hard-coded :class:`SSLObject`.
1912 Get statistics about the SSL sessions created or managed by this context.
1913 …names of each `piece of information <https://www.openssl.org/docs/man1.1.1/ssl/SSL_CTX_sess_number…
1936 import socket, ssl
1938 context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
1939 context.verify_mode = ssl.CERT_REQUIRED
1961 as Wireshark. The log file is opened in append-only mode. Writes are
1970 The attribute is read-only for protocols other than :attr:`PROTOCOL_TLS`,
1975 :attr:`SSLContext.options` all affect the supported SSL
2001 An integer representing the set of SSL options enabled on this context.
2008 >>> ssl.create_default_context().options # doctest: +SKIP
2019 Enable TLS 1.3 post-handshake client authentication. Post-handshake auth
2024 When enabled on client-side sockets, the client signals the server that
2025 it supports post-handshake authentication.
2027 When enabled on server-side sockets, :attr:`SSLContext.verify_mode` must
2038 is read-only.
2057 for the context. This attribute is read-only.
2072 >>> ssl.create_default_context().verify_flags # doctest: +SKIP
2084 >>> ssl.create_default_context().verify_mode
2091 .. _ssl-certificates:
2094 ------------
2096 Certificates in general are part of a public-key / private-key system. In this
2098 organization) is assigned a unique two-part encryption key. One part of the key
2125 (see :rfc:`1422`), which is a base-64 encoded form wrapped with a header line
2128 -----BEGIN CERTIFICATE-----
2130 -----END CERTIFICATE-----
2140 you get to a certificate which is *self-signed*, that is, a certificate which
2148 -----BEGIN CERTIFICATE-----
2150 -----END CERTIFICATE-----
2151 -----BEGIN CERTIFICATE-----
2153 -----END CERTIFICATE-----
2154 -----BEGIN CERTIFICATE-----
2156 -----END CERTIFICATE-----
2178 -----BEGIN RSA PRIVATE KEY-----
2180 -----END RSA PRIVATE KEY-----
2181 -----BEGIN CERTIFICATE-----
2183 -----END CERTIFICATE-----
2185 Self-signed certificates
2188 If you are going to create a server that provides SSL-encrypted connection
2191 certification authority. Another common practice is to generate a self-signed
2195 % openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem
2200 -----
2207 -----
2209 State or Province Name (full name) [Some-State]:MyState
2217 The disadvantage of a self-signed certificate is that it is its own root
2223 --------
2225 Testing for SSL support
2228 To test for the presence of SSL support in a Python installation, user code
2232 import ssl
2236 ... # do something that requires SSL support
2238 Client-side operation
2241 This example creates a SSL context with the recommended security settings
2244 >>> context = ssl.create_default_context()
2250 >>> context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2251 >>> context.load_verify_locations("/etc/ssl/certs/ca-bundle.crt")
2254 certificates in ``/etc/ssl/certs/ca-bundle.crt``; if not, you'll get an
2260 to ``True``. All other protocols create SSL contexts with insecure defaults.
2282 'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ev-server-g1.crl',
2283 'http://crl4.digicert.com/sha2-ev-server-g1.crl'),
2296 (('postalCode', '03894-4801'),),
2319 Now the SSL channel is established and the certificate verified, you can
2327 b'Content-Type: text/html; charset=utf-8',
2328 b'X-Frame-Options: SAMEORIGIN',
2329 b'Content-Length: 45679',
2330 b'Accept-Ranges: bytes',
2333 b'X-Served-By: cache-lcy1134-LCY',
2334 b'X-Cache: HIT',
2335 b'X-Cache-Hits: 11',
2337 b'Strict-Transport-Security: max-age=63072000; includeSubDomains',
2342 See the discussion of :ref:`ssl-security` below.
2345 Server-side operation
2354 import socket, ssl
2356 context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
2365 method to create a server-side SSL socket for the connection::
2392 the sockets in :ref:`non-blocking mode <ssl-nonblocking>` and use an event loop).
2395 .. _ssl-nonblocking:
2397 Notes on non-blocking sockets
2398 -----------------------------
2400 SSL sockets behave slightly different than regular sockets in
2401 non-blocking mode. When working with non-blocking sockets, there are
2404 - Most :class:`SSLSocket` methods will raise either
2410 *write* to an SSL socket may require *reading* from the underlying
2411 socket first, and attempts to *read* from the SSL socket may require
2420 - Calling :func:`~select.select` tells you that the OS-level socket can be
2422 data at the upper SSL layer. For example, only part of an SSL frame might
2427 - Conversely, since the SSL layer has its own framing, a SSL socket may
2436 - The SSL handshake itself will be non-blocking: the
2445 except ssl.SSLWantReadError:
2447 except ssl.SSLWantWriteError:
2452 The :mod:`asyncio` module supports :ref:`non-blocking SSL sockets
2453 <ssl-nonblocking>` and provides a
2456 :exc:`BlockingIOError` exceptions. It runs the SSL handshake asynchronously
2461 ------------------
2465 Ever since the SSL module was introduced in Python 2.6, the :class:`SSLSocket`
2468 - SSL protocol handling
2469 - Network IO
2472 from which :class:`SSLSocket` also inherits. This allows an SSL socket to be
2473 used as a drop-in replacement for a regular socket, making it very easy to add
2474 SSL support to an existing application.
2476 Combining SSL protocol handling and network IO usually works well, but there
2487 A reduced-scope variant of :class:`SSLSocket` representing an SSL protocol
2490 for SSL through memory buffers.
2492 This class implements an interface on top of a low-level SSL object as
2493 implemented by OpenSSL. This object captures the state of an SSL connection
2501 SSL protocol instance, while the *outgoing* BIO is used to pass data the
2506 - :attr:`~SSLSocket.context`
2507 - :attr:`~SSLSocket.server_side`
2508 - :attr:`~SSLSocket.server_hostname`
2509 - :attr:`~SSLSocket.session`
2510 - :attr:`~SSLSocket.session_reused`
2511 - :meth:`~SSLSocket.read`
2512 - :meth:`~SSLSocket.write`
2513 - :meth:`~SSLSocket.getpeercert`
2514 - :meth:`~SSLSocket.selected_alpn_protocol`
2515 - :meth:`~SSLSocket.selected_npn_protocol`
2516 - :meth:`~SSLSocket.cipher`
2517 - :meth:`~SSLSocket.shared_ciphers`
2518 - :meth:`~SSLSocket.compression`
2519 - :meth:`~SSLSocket.pending`
2520 - :meth:`~SSLSocket.do_handshake`
2521 - :meth:`~SSLSocket.verify_client_post_handshake`
2522 - :meth:`~SSLSocket.unwrap`
2523 - :meth:`~SSLSocket.get_channel_binding`
2524 - :meth:`~SSLSocket.version`
2529 - Any form of network IO; ``recv()`` and ``send()`` read and write only to
2532 - There is no *do_handshake_on_connect* machinery. You must always manually
2535 - There is no handling of *suppress_ragged_eofs*. All end-of-file conditions
2539 - The method :meth:`~SSLSocket.unwrap` call does not return anything,
2540 unlike for an SSL socket where it returns the underlying socket.
2542 - The *server_name_callback* callback passed to
2548 - All IO on an :class:`SSLObject` is :ref:`non-blocking <ssl-nonblocking>`.
2553 - There is no module-level ``wrap_bio()`` call like there is for
2569 A memory buffer that can be used to pass data between Python and an SSL
2578 A boolean indicating whether the memory BIO is current at the end-of-file
2581 .. method:: MemoryBIO.read(n=-1)
2601 SSL session
2602 -----------
2617 .. _ssl-security:
2620 -----------------------
2627 :func:`create_default_context` function to create your SSL context.
2628 It will load the system's trusted CA certificates, enable certificate
2635 >>> import ssl, smtplib
2637 >>> context = ssl.create_default_context()
2644 By contrast, if you create the SSL context by calling the :class:`SSLContext`
2672 In server mode, if you want to authenticate your clients using the SSL layer
2673 (rather than using a higher-level authentication mechanism), you'll also have
2680 SSL versions 2 and 3 are considered insecure and are therefore dangerous to
2688 >>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2689 >>> client_context.minimum_version = ssl.TLSVersion.TLSv1_3
2690 >>> client_context.maximum_version = ssl.TLSVersion.TLSv1_3
2693 The SSL context created above will only allow TLSv1.2 and later (if
2702 If you have advanced security requirements, fine-tuning of the ciphers
2703 enabled when negotiating a SSL session is possible through the
2705 ssl module disables certain weak ciphers by default, but you may want
2707 …cipher list format <https://www.openssl.org/docs/manmaster/man1/ciphers.html#CIPHER-LIST-FORMAT>`_.
2708 If you want to check which ciphers are enabled by a given cipher list, use
2709 :meth:`SSLContext.get_ciphers` or the ``openssl ciphers`` command on your
2712 Multi-processing
2715 If using this module as part of a multi-processed application (using,
2719 parent process if they use any SSL feature with :func:`os.fork`. Any
2720 successful call of :func:`~ssl.RAND_add`, :func:`~ssl.RAND_bytes` or
2721 :func:`~ssl.RAND_pseudo_bytes` is sufficient.
2724 .. _ssl-tlsv1_3:
2727 -------
2732 of TLS/SSL. Some new TLS 1.3 features are not yet available.
2734 - TLS 1.3 uses a disjunct set of cipher suites. All AES-GCM and
2736 :meth:`SSLContext.set_ciphers` cannot enable or disable any TLS 1.3
2737 ciphers yet, but :meth:`SSLContext.get_ciphers` returns them.
2738 - Session tickets are no longer sent as part of the initial handshake and
2741 - Client-side certificates are also no longer verified during the initial
2745 - TLS 1.3 features like early data, deferred TLS client cert request,
2754 …`SSL/TLS Strong Encryption: An Introduction <https://httpd.apache.org/docs/trunk/en/ssl/ssl_intro.…
2757 …:rfc:`RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key M…
2772 …ayer Security (TLS) Parameters <https://www.iana.org/assignments/tls-parameters/tls-parameters.xml…