@@ -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,
@@ -333,7 +334,7 @@ Exceptions
333
334
Random generation
334
335
^^^^^^^^^^^^^^^^^
335
336
336
- .. function :: RAND_bytes(num)
337
+ .. function :: RAND_bytes(num, / )
337
338
338
339
Return *num * cryptographically strong pseudo-random bytes. Raises an
339
340
:class: `SSLError ` if the PRNG has not been seeded with enough data or if the
@@ -357,7 +358,7 @@ Random generation
357
358
:func: `ssl.RAND_egd ` and :func: `ssl.RAND_add ` to increase the randomness of
358
359
the pseudo-random number generator.
359
360
360
- .. function :: RAND_add(bytes, entropy)
361
+ .. function :: RAND_add(bytes, entropy, / )
361
362
362
363
Mix the given *bytes * into the SSL pseudo-random number generator. The
363
364
parameter *entropy * (a float) is a lower bound on the entropy contained in
@@ -425,12 +426,12 @@ Certificate handling
425
426
.. versionchanged :: 3.10
426
427
The *timeout * parameter was added.
427
428
428
- .. function :: DER_cert_to_PEM_cert(DER_cert_bytes )
429
+ .. function :: DER_cert_to_PEM_cert(der_cert_bytes )
429
430
430
431
Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded
431
432
string version of the same certificate.
432
433
433
- .. function :: PEM_cert_to_DER_cert(PEM_cert_string )
434
+ .. function :: PEM_cert_to_DER_cert(pem_cert_string )
434
435
435
436
Given a certificate as an ASCII PEM string, returns a DER-encoded sequence of
436
437
bytes for that same certificate.
@@ -1160,10 +1161,10 @@ SSL sockets also have the following additional methods and attributes:
1160
1161
.. deprecated :: 3.6
1161
1162
Use :meth: `~SSLSocket.recv ` instead of :meth: `~SSLSocket.read `.
1162
1163
1163
- .. method :: SSLSocket.write(buf )
1164
+ .. method :: SSLSocket.write(data )
1164
1165
1165
- Write *buf * to the SSL socket and return the number of bytes written. The
1166
- *buf * argument must be an object supporting the buffer interface.
1166
+ Write *data * to the SSL socket and return the number of bytes written. The
1167
+ *data * argument must be an object supporting the buffer interface.
1167
1168
1168
1169
Raise :exc: `SSLWantReadError ` or :exc: `SSLWantWriteError ` if the socket is
1169
1170
:ref: `non-blocking <ssl-nonblocking >` and the write would block.
@@ -1173,7 +1174,7 @@ SSL sockets also have the following additional methods and attributes:
1173
1174
1174
1175
.. versionchanged :: 3.5
1175
1176
The socket timeout is no longer reset each time bytes are received or sent.
1176
- The socket timeout is now the maximum total duration to write *buf *.
1177
+ The socket timeout is now the maximum total duration to write *data *.
1177
1178
1178
1179
.. deprecated :: 3.6
1179
1180
Use :meth: `~SSLSocket.send ` instead of :meth: `~SSLSocket.write `.
@@ -1190,10 +1191,13 @@ SSL sockets also have the following additional methods and attributes:
1190
1191
:meth: `~socket.socket.recv ` and :meth: `~socket.socket.send ` instead of these
1191
1192
methods.
1192
1193
1193
- .. method :: SSLSocket.do_handshake()
1194
+ .. method :: SSLSocket.do_handshake(block=False )
1194
1195
1195
1196
Perform the SSL setup handshake.
1196
1197
1198
+ If *block * is true and the timeout obtained by :meth: `~socket.gettimeout `
1199
+ is zero, the socket is set in blocking mode until the handshake is performed.
1200
+
1197
1201
.. versionchanged :: 3.4
1198
1202
The handshake method also performs :func: `match_hostname ` when the
1199
1203
:attr: `~SSLContext.check_hostname ` attribute of the socket's
@@ -1717,7 +1721,7 @@ to speed up repeated connections from the same clients.
1717
1721
provided as part of the operating system, though, it is likely to be
1718
1722
configured properly.
1719
1723
1720
- .. method :: SSLContext.set_ciphers(ciphers)
1724
+ .. method :: SSLContext.set_ciphers(ciphers, / )
1721
1725
1722
1726
Set the allowed ciphers for sockets created with this context when
1723
1727
connecting using TLS 1.2 and earlier. The *ciphers * argument should
@@ -1733,7 +1737,7 @@ to speed up repeated connections from the same clients.
1733
1737
When connected, the :meth: `SSLSocket.cipher ` method of SSL sockets will
1734
1738
return details about the negotiated cipher.
1735
1739
1736
- .. method :: SSLContext.set_ciphersuites(ciphersuites)
1740
+ .. method :: SSLContext.set_ciphersuites(ciphersuites, / )
1737
1741
1738
1742
Set the allowed ciphers for sockets created with this context when
1739
1743
connecting using TLS 1.3. The *ciphersuites * argument should be a
@@ -1747,7 +1751,7 @@ to speed up repeated connections from the same clients.
1747
1751
1748
1752
.. versionadded :: next
1749
1753
1750
- .. method :: SSLContext.set_groups(groups)
1754
+ .. method :: SSLContext.set_groups(groups, / )
1751
1755
1752
1756
Set the groups allowed for key agreement for sockets created with this
1753
1757
context. It should be a string in the `OpenSSL group list format
@@ -1760,7 +1764,7 @@ to speed up repeated connections from the same clients.
1760
1764
1761
1765
.. versionadded :: next
1762
1766
1763
- .. method :: SSLContext.set_client_sigalgs(sigalgs)
1767
+ .. method :: SSLContext.set_client_sigalgs(sigalgs, / )
1764
1768
1765
1769
Set the signature algorithms allowed for certificate-based client
1766
1770
authentication. It should be a string in the `OpenSSL client sigalgs
@@ -1775,7 +1779,7 @@ to speed up repeated connections from the same clients.
1775
1779
1776
1780
.. versionadded :: next
1777
1781
1778
- .. method :: SSLContext.set_server_sigalgs(sigalgs)
1782
+ .. method :: SSLContext.set_server_sigalgs(sigalgs, / )
1779
1783
1780
1784
Set the signature algorithms allowed for the server to complete the TLS
1781
1785
handshake. It should be a string in the `OpenSSL sigalgs list format
@@ -1789,7 +1793,7 @@ to speed up repeated connections from the same clients.
1789
1793
1790
1794
.. versionadded :: next
1791
1795
1792
- .. method :: SSLContext.set_alpn_protocols(protocols )
1796
+ .. method :: SSLContext.set_alpn_protocols(alpn_protocols )
1793
1797
1794
1798
Specify which protocols the socket should advertise during the SSL/TLS
1795
1799
handshake. It should be a list of ASCII strings, like ``['http/1.1',
@@ -1803,7 +1807,7 @@ to speed up repeated connections from the same clients.
1803
1807
1804
1808
.. versionadded :: 3.5
1805
1809
1806
- .. method :: SSLContext.set_npn_protocols(protocols )
1810
+ .. method :: SSLContext.set_npn_protocols(npn_protocols )
1807
1811
1808
1812
Specify which protocols the socket should advertise during the SSL/TLS
1809
1813
handshake. It should be a list of strings, like ``['http/1.1', 'spdy/2'] ``,
@@ -1870,7 +1874,7 @@ to speed up repeated connections from the same clients.
1870
1874
1871
1875
.. versionadded :: 3.7
1872
1876
1873
- .. attribute :: SSLContext.set_servername_callback(server_name_callback)
1877
+ .. method :: SSLContext.set_servername_callback(server_name_callback)
1874
1878
1875
1879
This is a legacy API retained for backwards compatibility. When possible,
1876
1880
you should use :attr: `sni_callback ` instead. The given *server_name_callback *
@@ -1884,7 +1888,7 @@ to speed up repeated connections from the same clients.
1884
1888
1885
1889
.. versionadded :: 3.4
1886
1890
1887
- .. method :: SSLContext.load_dh_params(dhfile)
1891
+ .. method :: SSLContext.load_dh_params(dhfile, / )
1888
1892
1889
1893
Load the key generation parameters for Diffie-Hellman (DH) key exchange.
1890
1894
Using DH key exchange improves forward secrecy at the expense of
@@ -1897,7 +1901,7 @@ to speed up repeated connections from the same clients.
1897
1901
1898
1902
.. versionadded :: 3.3
1899
1903
1900
- .. method :: SSLContext.set_ecdh_curve(curve_name)
1904
+ .. method :: SSLContext.set_ecdh_curve(curve_name, / )
1901
1905
1902
1906
Set the curve name for Elliptic Curve-based Diffie-Hellman (ECDH) key
1903
1907
exchange. ECDH is significantly faster than regular DH while arguably
@@ -2771,12 +2775,12 @@ purpose. It wraps an OpenSSL memory BIO (Basic IO) object:
2771
2775
A boolean indicating whether the memory BIO is current at the end-of-file
2772
2776
position.
2773
2777
2774
- .. method :: MemoryBIO.read(n=-1)
2778
+ .. method :: MemoryBIO.read(n=-1, / )
2775
2779
2776
2780
Read up to *n * bytes from the memory buffer. If *n * is not specified or
2777
2781
negative, all bytes are returned.
2778
2782
2779
- .. method :: MemoryBIO.write(buf)
2783
+ .. method :: MemoryBIO.write(buf, / )
2780
2784
2781
2785
Write the bytes from *buf * to the memory BIO. The *buf * argument must be an
2782
2786
object supporting the buffer protocol.
0 commit comments