@@ -25,8 +25,8 @@ probably additional platforms, as long as OpenSSL is installed on that platform.
25
25
26
26
Some behavior may be platform dependent, since calls are made to the
27
27
operating system socket APIs. The installed version of OpenSSL may also
28
- cause variations in behavior. For example, TLSv1.1 and TLSv1.2 come with
29
- openssl version 1.0 .1.
28
+ cause variations in behavior. For example, TLSv1.3 with OpenSSL version
29
+ 1.1 .1.
30
30
31
31
.. warning ::
32
32
Don't use this module without reading the :ref: `ssl-security `. Doing so
@@ -63,6 +63,8 @@ by SSL sockets created through the :meth:`SSLContext.wrap_socket` method.
63
63
:pep: `644 ` has been implemented. The ssl module requires OpenSSL 1.1.1
64
64
or newer.
65
65
66
+ Use of deprecated constants and functions result in deprecation warnings.
67
+
66
68
67
69
Functions, Constants, and Exceptions
68
70
------------------------------------
@@ -136,8 +138,9 @@ purposes.
136
138
:const: `None `, this function can choose to trust the system's default
137
139
CA certificates instead.
138
140
139
- The settings are: :data: `PROTOCOL_TLS `, :data: `OP_NO_SSLv2 `, and
140
- :data: `OP_NO_SSLv3 ` with high encryption cipher suites without RC4 and
141
+ The settings are: :data: `PROTOCOL_TLS_CLIENT ` or
142
+ :data: `PROTOCOL_TLS_SERVER `, :data: `OP_NO_SSLv2 `, and :data: `OP_NO_SSLv3 `
143
+ with high encryption cipher suites without RC4 and
141
144
without unauthenticated cipher suites. Passing :data: `~Purpose.SERVER_AUTH `
142
145
as *purpose * sets :data: `~SSLContext.verify_mode ` to :data: `CERT_REQUIRED `
143
146
and either loads CA certificates (when at least one of *cafile *, *capath * or
@@ -185,6 +188,12 @@ purposes.
185
188
186
189
Support for key logging to :envvar: `SSLKEYLOGFILE ` was added.
187
190
191
+ .. versionchanged :: 3.10
192
+
193
+ The context now uses :data: `PROTOCOL_TLS_CLIENT ` or
194
+ :data: `PROTOCOL_TLS_SERVER ` protocol instead of generic
195
+ :data: `PROTOCOL_TLS `.
196
+
188
197
189
198
Exceptions
190
199
^^^^^^^^^^
@@ -417,7 +426,7 @@ Certificate handling
417
426
previously. Return an integer (no fractions of a second in the
418
427
input format)
419
428
420
- .. function :: get_server_certificate(addr, ssl_version=PROTOCOL_TLS , ca_certs=None)
429
+ .. function :: get_server_certificate(addr, ssl_version=PROTOCOL_TLS_CLIENT , ca_certs=None)
421
430
422
431
Given the address ``addr `` of an SSL-protected server, as a (*hostname *,
423
432
*port-number *) pair, fetches the server's certificate, and returns it as a
@@ -654,6 +663,8 @@ Constants
654
663
655
664
.. versionadded :: 3.6
656
665
666
+ .. deprecated :: 3.10
667
+
657
668
.. data :: PROTOCOL_TLS_CLIENT
658
669
659
670
Auto-negotiate the highest protocol version like :data: `PROTOCOL_TLS `,
@@ -707,16 +718,18 @@ Constants
707
718
.. deprecated :: 3.6
708
719
709
720
OpenSSL has deprecated all version specific protocols. Use the default
710
- protocol :data: `PROTOCOL_TLS ` with flags like :data: `OP_NO_SSLv3 ` instead.
721
+ protocol :data: `PROTOCOL_TLS_SERVER ` or :data: `PROTOCOL_TLS_CLIENT `
722
+ with :attr: `SSLContext.minimum_version ` and
723
+ :attr: `SSLContext.maximum_version ` instead.
724
+
711
725
712
726
.. data :: PROTOCOL_TLSv1
713
727
714
728
Selects TLS version 1.0 as the channel encryption protocol.
715
729
716
730
.. deprecated :: 3.6
717
731
718
- OpenSSL has deprecated all version specific protocols. Use the default
719
- protocol :data: `PROTOCOL_TLS ` with flags like :data: `OP_NO_SSLv3 ` instead.
732
+ OpenSSL has deprecated all version specific protocols.
720
733
721
734
.. data :: PROTOCOL_TLSv1_1
722
735
@@ -727,8 +740,7 @@ Constants
727
740
728
741
.. deprecated :: 3.6
729
742
730
- OpenSSL has deprecated all version specific protocols. Use the default
731
- protocol :data: `PROTOCOL_TLS ` with flags like :data: `OP_NO_SSLv3 ` instead.
743
+ OpenSSL has deprecated all version specific protocols.
732
744
733
745
.. data :: PROTOCOL_TLSv1_2
734
746
@@ -739,8 +751,7 @@ Constants
739
751
740
752
.. deprecated :: 3.6
741
753
742
- OpenSSL has deprecated all version specific protocols. Use the default
743
- protocol :data: `PROTOCOL_TLS ` with flags like :data: `OP_NO_SSLv3 ` instead.
754
+ OpenSSL has deprecated all version specific protocols.
744
755
745
756
.. data :: OP_ALL
746
757
@@ -762,7 +773,6 @@ Constants
762
773
763
774
SSLv2 is deprecated
764
775
765
-
766
776
.. data :: OP_NO_SSLv3
767
777
768
778
Prevents an SSLv3 connection. This option is only applicable in
@@ -1068,6 +1078,11 @@ Constants
1068
1078
1069
1079
SSL 3.0 to TLS 1.3.
1070
1080
1081
+ .. deprecated :: 3.10
1082
+
1083
+ All :class: `TLSVersion ` members except :attr: `TLSVersion.TLSv1_2 ` and
1084
+ :attr: `TLSVersion.TLSv1_3 ` are deprecated.
1085
+
1071
1086
1072
1087
SSL Sockets
1073
1088
-----------
@@ -1423,7 +1438,7 @@ such as SSL configuration options, certificate(s) and private key(s).
1423
1438
It also manages a cache of SSL sessions for server-side sockets, in order
1424
1439
to speed up repeated connections from the same clients.
1425
1440
1426
- .. class :: SSLContext(protocol=PROTOCOL_TLS )
1441
+ .. class :: SSLContext(protocol=None )
1427
1442
1428
1443
Create a new SSL context. You may pass *protocol * which must be one
1429
1444
of the ``PROTOCOL_* `` constants defined in this module. The parameter
@@ -1472,6 +1487,12 @@ to speed up repeated connections from the same clients.
1472
1487
ciphers, no ``NULL `` ciphers and no ``MD5 `` ciphers (except for
1473
1488
:data: `PROTOCOL_SSLv2 `).
1474
1489
1490
+ .. deprecated :: 3.10
1491
+
1492
+ :class: `SSLContext ` without protocol argument is deprecated. The
1493
+ context class will either require :data: `PROTOCOL_TLS_CLIENT ` or
1494
+ :data: `PROTOCOL_TLS_SERVER ` protocol in the future.
1495
+
1475
1496
1476
1497
:class: `SSLContext ` objects have the following methods and attributes:
1477
1498
@@ -1934,7 +1955,7 @@ to speed up repeated connections from the same clients.
1934
1955
.. attribute :: SSLContext.num_tickets
1935
1956
1936
1957
Control the number of TLS 1.3 session tickets of a
1937
- :attr: `TLS_PROTOCOL_SERVER ` context. The setting has no impact on TLS
1958
+ :attr: `PROTOCOL_TLS_SERVER ` context. The setting has no impact on TLS
1938
1959
1.0 to 1.2 connections.
1939
1960
1940
1961
.. versionadded :: 3.8
@@ -1951,6 +1972,12 @@ to speed up repeated connections from the same clients.
1951
1972
>>> ssl.create_default_context().options # doctest: +SKIP
1952
1973
<Options.OP_ALL|OP_NO_SSLv3|OP_NO_SSLv2|OP_NO_COMPRESSION: 2197947391>
1953
1974
1975
+ .. deprecated :: 3.7
1976
+
1977
+ All ``OP_NO_SSL* `` and ``OP_NO_TLS* `` options have been deprecated since
1978
+ Python 3.7. Use :attr: `SSLContext.minimum_version ` and
1979
+ :attr: `SSLContext.maximum_version ` instead.
1980
+
1954
1981
.. attribute :: SSLContext.post_handshake_auth
1955
1982
1956
1983
Enable TLS 1.3 post-handshake client authentication. Post-handshake auth
@@ -2623,8 +2650,8 @@ disabled by default.
2623
2650
::
2624
2651
2625
2652
>>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2626
- >>> client_context.options | = ssl.OP_NO_TLSv1
2627
- >>> client_context.options | = ssl.OP_NO_TLSv1_1
2653
+ >>> client_context.minimum_version = ssl.TLSVersion.TLSv1_3
2654
+ >>> client_context.maximum_version = ssl.TLSVersion.TLSv1_3
2628
2655
2629
2656
2630
2657
The SSL context created above will only allow TLSv1.2 and later (if
0 commit comments