@@ -125,7 +125,8 @@ Context creation
125
125
A convenience function helps create :class: `SSLContext ` objects for common
126
126
purposes.
127
127
128
- .. function :: create_default_context(purpose=Purpose.SERVER_AUTH, cafile=None, capath=None, cadata=None)
128
+ .. function :: create_default_context(purpose=Purpose.SERVER_AUTH, *,\
129
+ cafile=None, capath=None, cadata=None)
129
130
130
131
Return a new :class: `SSLContext ` object with default settings for
131
132
the given *purpose *. The settings are chosen by the :mod: `ssl ` module,
@@ -314,7 +315,7 @@ Exceptions
314
315
Random generation
315
316
^^^^^^^^^^^^^^^^^
316
317
317
- .. function :: RAND_bytes(num)
318
+ .. function :: RAND_bytes(num, / )
318
319
319
320
Return *num * cryptographically strong pseudo-random bytes. Raises an
320
321
:class: `SSLError ` if the PRNG has not been seeded with enough data or if the
@@ -338,7 +339,7 @@ Random generation
338
339
:func: `ssl.RAND_egd ` and :func: `ssl.RAND_add ` to increase the randomness of
339
340
the pseudo-random number generator.
340
341
341
- .. function :: RAND_add(bytes, entropy)
342
+ .. function :: RAND_add(bytes, entropy, / )
342
343
343
344
Mix the given *bytes * into the SSL pseudo-random number generator. The
344
345
parameter *entropy * (a float) is a lower bound on the entropy contained in
@@ -406,12 +407,12 @@ Certificate handling
406
407
.. versionchanged :: 3.10
407
408
The *timeout * parameter was added.
408
409
409
- .. function :: DER_cert_to_PEM_cert(DER_cert_bytes )
410
+ .. function :: DER_cert_to_PEM_cert(der_cert_bytes )
410
411
411
412
Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded
412
413
string version of the same certificate.
413
414
414
- .. function :: PEM_cert_to_DER_cert(PEM_cert_string )
415
+ .. function :: PEM_cert_to_DER_cert(pem_cert_string )
415
416
416
417
Given a certificate as an ASCII PEM string, returns a DER-encoded sequence of
417
418
bytes for that same certificate.
@@ -1128,10 +1129,10 @@ SSL sockets also have the following additional methods and attributes:
1128
1129
.. deprecated :: 3.6
1129
1130
Use :meth: `~SSLSocket.recv ` instead of :meth: `~SSLSocket.read `.
1130
1131
1131
- .. method :: SSLSocket.write(buf )
1132
+ .. method :: SSLSocket.write(data )
1132
1133
1133
- Write *buf * to the SSL socket and return the number of bytes written. The
1134
- *buf * argument must be an object supporting the buffer interface.
1134
+ Write *data * to the SSL socket and return the number of bytes written. The
1135
+ *data * argument must be an object supporting the buffer interface.
1135
1136
1136
1137
Raise :exc: `SSLWantReadError ` or :exc: `SSLWantWriteError ` if the socket is
1137
1138
:ref: `non-blocking <ssl-nonblocking >` and the write would block.
@@ -1141,7 +1142,7 @@ SSL sockets also have the following additional methods and attributes:
1141
1142
1142
1143
.. versionchanged :: 3.5
1143
1144
The socket timeout is no longer reset each time bytes are received or sent.
1144
- The socket timeout is now the maximum total duration to write *buf *.
1145
+ The socket timeout is now the maximum total duration to write *data *.
1145
1146
1146
1147
.. deprecated :: 3.6
1147
1148
Use :meth: `~SSLSocket.send ` instead of :meth: `~SSLSocket.write `.
@@ -1158,12 +1159,15 @@ SSL sockets also have the following additional methods and attributes:
1158
1159
:meth: `~socket.socket.recv ` and :meth: `~socket.socket.send ` instead of these
1159
1160
methods.
1160
1161
1161
- .. method :: SSLSocket.do_handshake()
1162
+ .. method :: SSLSocket.do_handshake(block=False )
1162
1163
1163
1164
Perform the SSL setup handshake.
1164
1165
1166
+ If *block * is true and the timeout obtained by :meth: `~socket.socket.gettimeout `
1167
+ is zero, the socket is set in blocking mode until the handshake is performed.
1168
+
1165
1169
.. versionchanged :: 3.4
1166
- The handshake method also performs :func: `match_hostname ` when the
1170
+ The handshake method also performs :func: `! match_hostname ` when the
1167
1171
:attr: `~SSLContext.check_hostname ` attribute of the socket's
1168
1172
:attr: `~SSLSocket.context ` is true.
1169
1173
@@ -1173,7 +1177,7 @@ SSL sockets also have the following additional methods and attributes:
1173
1177
1174
1178
.. versionchanged :: 3.7
1175
1179
Hostname or IP address is matched by OpenSSL during handshake. The
1176
- function :func: `match_hostname ` is no longer used. In case OpenSSL
1180
+ function :func: `! match_hostname ` is no longer used. In case OpenSSL
1177
1181
refuses a hostname or IP address, the handshake is aborted early and
1178
1182
a TLS alert message is sent to the peer.
1179
1183
@@ -1643,7 +1647,7 @@ to speed up repeated connections from the same clients.
1643
1647
provided as part of the operating system, though, it is likely to be
1644
1648
configured properly.
1645
1649
1646
- .. method :: SSLContext.set_ciphers(ciphers)
1650
+ .. method :: SSLContext.set_ciphers(ciphers, / )
1647
1651
1648
1652
Set the available ciphers for sockets created with this context.
1649
1653
It should be a string in the `OpenSSL cipher list format
@@ -1659,7 +1663,7 @@ to speed up repeated connections from the same clients.
1659
1663
TLS 1.3 cipher suites cannot be disabled with
1660
1664
:meth: `~SSLContext.set_ciphers `.
1661
1665
1662
- .. method :: SSLContext.set_alpn_protocols(protocols )
1666
+ .. method :: SSLContext.set_alpn_protocols(alpn_protocols )
1663
1667
1664
1668
Specify which protocols the socket should advertise during the SSL/TLS
1665
1669
handshake. It should be a list of ASCII strings, like ``['http/1.1',
@@ -1673,7 +1677,7 @@ to speed up repeated connections from the same clients.
1673
1677
1674
1678
.. versionadded :: 3.5
1675
1679
1676
- .. method :: SSLContext.set_npn_protocols(protocols )
1680
+ .. method :: SSLContext.set_npn_protocols(npn_protocols )
1677
1681
1678
1682
Specify which protocols the socket should advertise during the SSL/TLS
1679
1683
handshake. It should be a list of strings, like ``['http/1.1', 'spdy/2'] ``,
@@ -1740,7 +1744,7 @@ to speed up repeated connections from the same clients.
1740
1744
1741
1745
.. versionadded :: 3.7
1742
1746
1743
- .. attribute :: SSLContext.set_servername_callback(server_name_callback)
1747
+ .. method :: SSLContext.set_servername_callback(server_name_callback)
1744
1748
1745
1749
This is a legacy API retained for backwards compatibility. When possible,
1746
1750
you should use :attr: `sni_callback ` instead. The given *server_name_callback *
@@ -1754,7 +1758,7 @@ to speed up repeated connections from the same clients.
1754
1758
1755
1759
.. versionadded :: 3.4
1756
1760
1757
- .. method :: SSLContext.load_dh_params(dhfile)
1761
+ .. method :: SSLContext.load_dh_params(dhfile, / )
1758
1762
1759
1763
Load the key generation parameters for Diffie-Hellman (DH) key exchange.
1760
1764
Using DH key exchange improves forward secrecy at the expense of
@@ -1767,7 +1771,7 @@ to speed up repeated connections from the same clients.
1767
1771
1768
1772
.. versionadded :: 3.3
1769
1773
1770
- .. method :: SSLContext.set_ecdh_curve(curve_name)
1774
+ .. method :: SSLContext.set_ecdh_curve(curve_name, / )
1771
1775
1772
1776
Set the curve name for Elliptic Curve-based Diffie-Hellman (ECDH) key
1773
1777
exchange. ECDH is significantly faster than regular DH while arguably
@@ -2641,12 +2645,12 @@ purpose. It wraps an OpenSSL memory BIO (Basic IO) object:
2641
2645
A boolean indicating whether the memory BIO is current at the end-of-file
2642
2646
position.
2643
2647
2644
- .. method :: MemoryBIO.read(n=-1)
2648
+ .. method :: MemoryBIO.read(n=-1, / )
2645
2649
2646
2650
Read up to *n * bytes from the memory buffer. If *n * is not specified or
2647
2651
negative, all bytes are returned.
2648
2652
2649
- .. method :: MemoryBIO.write(buf)
2653
+ .. method :: MemoryBIO.write(buf, / )
2650
2654
2651
2655
Write the bytes from *buf * to the memory BIO. The *buf * argument must be an
2652
2656
object supporting the buffer protocol.
@@ -2729,7 +2733,7 @@ This common check is automatically performed when
2729
2733
2730
2734
.. versionchanged :: 3.7
2731
2735
Hostname matchings is now performed by OpenSSL. Python no longer uses
2732
- :func: `match_hostname `.
2736
+ :func: `! match_hostname `.
2733
2737
2734
2738
In server mode, if you want to authenticate your clients using the SSL layer
2735
2739
(rather than using a higher-level authentication mechanism), you'll also have
0 commit comments