@@ -178,7 +178,7 @@ instead.
178178 use. Typically, the server chooses a particular protocol version, and the
179179 client must adapt to the server's choice. Most of the versions are not
180180 interoperable with the other versions. If not specified, the default is
181- :data: `PROTOCOL_SSLv23 `; it provides the most compatibility with other
181+ :data: `PROTOCOL_TLS `; it provides the most compatibility with other
182182 versions.
183183
184184 Here's a table showing which versions in a client (down the side) can connect
@@ -187,11 +187,11 @@ instead.
187187 .. table ::
188188
189189 ======================== ========= ========= ========== ========= =========== ===========
190- *client * / **server ** **SSLv2 ** **SSLv3 ** **SSLv23 ** **TLSv1 ** **TLSv1.1 ** **TLSv1.2 **
190+ *client * / **server ** **SSLv2 ** **SSLv3 ** **TLS ** **TLSv1 ** **TLSv1.1 ** **TLSv1.2 **
191191 ------------------------ --------- --------- ---------- --------- ----------- -----------
192192 *SSLv2 * yes no yes no no no
193193 *SSLv3 * no yes yes no no no
194- *SSLv23 * no yes yes yes yes yes
194+ *TLS * (* SSLv23 *) no yes yes yes yes yes
195195 *TLSv1 * no no yes yes no no
196196 *TLSv1.1 * no no yes no yes no
197197 *TLSv1.2 * no no yes no no yes
@@ -244,7 +244,7 @@ purposes.
244244 :const: `None `, this function can choose to trust the system's default
245245 CA certificates instead.
246246
247- The settings are: :data: `PROTOCOL_SSLv23 `, :data: `OP_NO_SSLv2 `, and
247+ The settings are: :data: `PROTOCOL_TLS `, :data: `OP_NO_SSLv2 `, and
248248 :data: `OP_NO_SSLv3 ` with high encryption cipher suites without RC4 and
249249 without unauthenticated cipher suites. Passing :data: `~Purpose.SERVER_AUTH `
250250 as *purpose * sets :data: `~SSLContext.verify_mode ` to :data: `CERT_REQUIRED `
@@ -316,6 +316,11 @@ Random generation
316316
317317 .. versionadded :: 3.3
318318
319+ .. deprecated :: 3.5.3
320+
321+ OpenSSL has deprecated :func: `ssl.RAND_pseudo_bytes `, use
322+ :func: `ssl.RAND_bytes ` instead.
323+
319324.. function :: RAND_status()
320325
321326 Return ``True `` if the SSL pseudo-random number generator has been seeded
@@ -334,7 +339,7 @@ Random generation
334339 See http://egd.sourceforge.net/ or http://prngd.sourceforge.net/ for sources
335340 of entropy-gathering daemons.
336341
337- Availability: not available with LibreSSL.
342+ Availability: not available with LibreSSL and OpenSSL > 1.1.0
338343
339344.. function :: RAND_add(bytes, entropy)
340345
@@ -409,7 +414,7 @@ Certificate handling
409414 previously. Return an integer (no fractions of a second in the
410415 input format)
411416
412- .. function :: get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23 , ca_certs=None)
417+ .. function :: get_server_certificate(addr, ssl_version=PROTOCOL_TLS , ca_certs=None)
413418
414419 Given the address ``addr `` of an SSL-protected server, as a (*hostname *,
415420 *port-number *) pair, fetches the server's certificate, and returns it as a
@@ -425,7 +430,7 @@ Certificate handling
425430
426431 .. versionchanged :: 3.5
427432 The default *ssl_version * is changed from :data: `PROTOCOL_SSLv3 ` to
428- :data: `PROTOCOL_SSLv23 ` for maximum compatibility with modern servers.
433+ :data: `PROTOCOL_TLS ` for maximum compatibility with modern servers.
429434
430435.. function :: DER_cert_to_PEM_cert(DER_cert_bytes)
431436
@@ -451,6 +456,9 @@ Certificate handling
451456 * :attr: `openssl_capath_env ` - OpenSSL's environment key that points to a capath,
452457 * :attr: `openssl_capath ` - hard coded path to a capath directory
453458
459+ Availability: LibreSSL ignores the environment vars
460+ :attr: `openssl_cafile_env ` and :attr: `openssl_capath_env `
461+
454462 .. versionadded :: 3.4
455463
456464.. function :: enum_certificates(store_name)
@@ -568,11 +576,21 @@ Constants
568576
569577 .. versionadded :: 3.4.4
570578
571- .. data :: PROTOCOL_SSLv23
579+ .. data :: PROTOCOL_TLS
572580
573581 Selects the highest protocol version that both the client and server support.
574582 Despite the name, this option can select "TLS" protocols as well as "SSL".
575583
584+ .. versionadded :: 3.5.3
585+
586+ .. data :: PROTOCOL_SSLv23
587+
588+ Alias for data:`PROTOCOL_TLS `.
589+
590+ .. deprecated :: 3.5.3
591+
592+ Use data:`PROTOCOL_TLS ` instead.
593+
576594.. data :: PROTOCOL_SSLv2
577595
578596 Selects SSL version 2 as the channel encryption protocol.
@@ -584,6 +602,10 @@ Constants
584602
585603 SSL version 2 is insecure. Its use is highly discouraged.
586604
605+ .. deprecated :: 3.5.3
606+
607+ OpenSSL has removed support for SSLv2.
608+
587609.. data :: PROTOCOL_SSLv3
588610
589611 Selects SSL version 3 as the channel encryption protocol.
@@ -595,17 +617,32 @@ Constants
595617
596618 SSL version 3 is insecure. Its use is highly discouraged.
597619
620+ .. deprecated :: 3.5.3
621+
622+ OpenSSL has deprecated all version specific protocols. Use the default
623+ protocol data:`PROTOCOL_TLS ` with flags like data:`OP_NO_SSLv3 ` instead.
624+
598625.. data :: PROTOCOL_TLSv1
599626
600627 Selects TLS version 1.0 as the channel encryption protocol.
601628
629+ .. deprecated :: 3.5.3
630+
631+ OpenSSL has deprecated all version specific protocols. Use the default
632+ protocol data:`PROTOCOL_TLS ` with flags like data:`OP_NO_SSLv3 ` instead.
633+
602634.. data :: PROTOCOL_TLSv1_1
603635
604636 Selects TLS version 1.1 as the channel encryption protocol.
605637 Available only with openssl version 1.0.1+.
606638
607639 .. versionadded :: 3.4
608640
641+ .. deprecated :: 3.5.3
642+
643+ OpenSSL has deprecated all version specific protocols. Use the default
644+ protocol data:`PROTOCOL_TLS ` with flags like data:`OP_NO_SSLv3 ` instead.
645+
609646.. data :: PROTOCOL_TLSv1_2
610647
611648 Selects TLS version 1.2 as the channel encryption protocol. This is the
@@ -614,6 +651,11 @@ Constants
614651
615652 .. versionadded :: 3.4
616653
654+ .. deprecated :: 3.5.3
655+
656+ OpenSSL has deprecated all version specific protocols. Use the default
657+ protocol data:`PROTOCOL_TLS ` with flags like data:`OP_NO_SSLv3 ` instead.
658+
617659.. data :: OP_ALL
618660
619661 Enables workarounds for various bugs present in other SSL implementations.
@@ -625,39 +667,48 @@ Constants
625667.. data :: OP_NO_SSLv2
626668
627669 Prevents an SSLv2 connection. This option is only applicable in
628- conjunction with :const: `PROTOCOL_SSLv23 `. It prevents the peers from
670+ conjunction with :const: `PROTOCOL_TLS `. It prevents the peers from
629671 choosing SSLv2 as the protocol version.
630672
631673 .. versionadded :: 3.2
632674
675+ .. deprecated :: 3.5.3
676+
677+ SSLv2 is deprecated
678+
679+
633680.. data :: OP_NO_SSLv3
634681
635682 Prevents an SSLv3 connection. This option is only applicable in
636- conjunction with :const: `PROTOCOL_SSLv23 `. It prevents the peers from
683+ conjunction with :const: `PROTOCOL_TLS `. It prevents the peers from
637684 choosing SSLv3 as the protocol version.
638685
639686 .. versionadded :: 3.2
640687
688+ .. deprecated :: 3.5.3
689+
690+ SSLv3 is deprecated
691+
641692.. data :: OP_NO_TLSv1
642693
643694 Prevents a TLSv1 connection. This option is only applicable in
644- conjunction with :const: `PROTOCOL_SSLv23 `. It prevents the peers from
695+ conjunction with :const: `PROTOCOL_TLS `. It prevents the peers from
645696 choosing TLSv1 as the protocol version.
646697
647698 .. versionadded :: 3.2
648699
649700.. data :: OP_NO_TLSv1_1
650701
651702 Prevents a TLSv1.1 connection. This option is only applicable in conjunction
652- with :const: `PROTOCOL_SSLv23 `. It prevents the peers from choosing TLSv1.1 as
703+ with :const: `PROTOCOL_TLS `. It prevents the peers from choosing TLSv1.1 as
653704 the protocol version. Available only with openssl version 1.0.1+.
654705
655706 .. versionadded :: 3.4
656707
657708.. data :: OP_NO_TLSv1_2
658709
659710 Prevents a TLSv1.2 connection. This option is only applicable in conjunction
660- with :const: `PROTOCOL_SSLv23 `. It prevents the peers from choosing TLSv1.2 as
711+ with :const: `PROTOCOL_TLS `. It prevents the peers from choosing TLSv1.2 as
661712 the protocol version. Available only with openssl version 1.0.1+.
662713
663714 .. versionadded :: 3.4
@@ -1081,17 +1132,21 @@ such as SSL configuration options, certificate(s) and private key(s).
10811132It also manages a cache of SSL sessions for server-side sockets, in order
10821133to speed up repeated connections from the same clients.
10831134
1084- .. class :: SSLContext(protocol)
1135+ .. class :: SSLContext(protocol=PROTOCOL_TLS )
10851136
1086- Create a new SSL context. You must pass *protocol * which must be one
1137+ Create a new SSL context. You may pass *protocol * which must be one
10871138 of the ``PROTOCOL_* `` constants defined in this module.
1088- :data: `PROTOCOL_SSLv23 ` is currently recommended for maximum
1089- interoperability.
1139+ :data: `PROTOCOL_TLS ` is currently recommended for maximum
1140+ interoperability and default value .
10901141
10911142 .. seealso ::
10921143 :func: `create_default_context ` lets the :mod: `ssl ` module choose
10931144 security settings for a given purpose.
10941145
1146+ .. versionchanged :: 3.5.3
1147+
1148+ :data: `PROTOCOL_TLS ` is the default value.
1149+
10951150
10961151:class: `SSLContext ` objects have the following methods and attributes:
10971152
@@ -1232,6 +1287,9 @@ to speed up repeated connections from the same clients.
12321287 This method will raise :exc: `NotImplementedError ` if :data: `HAS_ALPN ` is
12331288 False.
12341289
1290+ OpenSSL 1.1.0+ will abort the handshake and raise :exc: `SSLError ` when
1291+ both sides support ALPN but cannot agree on a protocol.
1292+
12351293 .. versionadded :: 3.5
12361294
12371295.. method :: SSLContext.set_npn_protocols(protocols)
@@ -1598,7 +1656,7 @@ If you prefer to tune security settings yourself, you might create
15981656a context from scratch (but beware that you might not get the settings
15991657right)::
16001658
1601- >>> context = ssl.SSLContext(ssl.PROTOCOL_SSLv23 )
1659+ >>> context = ssl.SSLContext(ssl.PROTOCOL_TLS )
16021660 >>> context.verify_mode = ssl.CERT_REQUIRED
16031661 >>> context.check_hostname = True
16041662 >>> context.load_verify_locations("/etc/ssl/certs/ca-bundle.crt")
@@ -1999,15 +2057,17 @@ Protocol versions
19992057
20002058SSL versions 2 and 3 are considered insecure and are therefore dangerous to
20012059use. If you want maximum compatibility between clients and servers, it is
2002- recommended to use :const: `PROTOCOL_SSLv23 ` as the protocol version and then
2060+ recommended to use :const: `PROTOCOL_TLS ` as the protocol version and then
20032061disable SSLv2 and SSLv3 explicitly using the :data: `SSLContext.options `
20042062attribute::
20052063
2006- context = ssl.SSLContext(ssl.PROTOCOL_SSLv23 )
2064+ context = ssl.SSLContext(ssl.PROTOCOL_TLS )
20072065 context.options |= ssl.OP_NO_SSLv2
20082066 context.options |= ssl.OP_NO_SSLv3
2067+ context.options |= ssl.OP_NO_TLSv1
2068+ context.options |= ssl.OP_NO_TLSv1_1
20092069
2010- The SSL context created above will only allow TLSv1 and later (if
2070+ The SSL context created above will only allow TLSv1.2 and later (if
20112071supported by your system) connections.
20122072
20132073Cipher selection
0 commit comments