-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-94199: Remove ssl.wrap_socket() documentation #99023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
gh-94199: Remove ssl.wrap_socket() documentation
The function has been removed. In the ssl documentation, replace references to the ssl.wrap_socket() function with references to the ssl.SSLContext.wrap_socket() method.
- Loading branch information
commit 5e11f40e041d050d73955ad3bc336ba0c1ea78d9
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,13 +74,11 @@ Functions, Constants, and Exceptions | |
| Socket creation | ||
| ^^^^^^^^^^^^^^^ | ||
|
|
||
| Since Python 3.2 and 2.7.9, it is recommended to use the | ||
| Since Python 3.2, it is recommended to use the | ||
| :meth:`SSLContext.wrap_socket` of an :class:`SSLContext` instance to wrap | ||
| sockets as :class:`SSLSocket` objects. The helper functions | ||
| sockets as :class:`SSLSocket` objects. The helper function | ||
| :func:`create_default_context` returns a new context with secure default | ||
| settings. The old :func:`wrap_socket` function is deprecated since it is | ||
| both inefficient and has no support for server name indication (SNI) and | ||
| hostname matching. | ||
| settings. | ||
|
|
||
| Client socket example with default context and IPv4/IPv6 dual stack:: | ||
|
|
||
|
|
@@ -451,33 +449,6 @@ Certificate handling | |
|
|
||
| .. versionadded:: 3.4 | ||
|
|
||
| .. function:: wrap_socket(sock, keyfile=None, certfile=None, \ | ||
| server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_TLS, \ | ||
| ca_certs=None, do_handshake_on_connect=True, \ | ||
| suppress_ragged_eofs=True, ciphers=None) | ||
|
|
||
| Takes an instance ``sock`` of :class:`socket.socket`, and returns an instance | ||
| of :class:`ssl.SSLSocket`, a subtype of :class:`socket.socket`, which wraps | ||
| the underlying socket in an SSL context. ``sock`` must be a | ||
| :data:`~socket.SOCK_STREAM` socket; other socket types are unsupported. | ||
|
|
||
| Internally, function creates a :class:`SSLContext` with protocol | ||
| *ssl_version* and :attr:`SSLContext.options` set to *cert_reqs*. If | ||
| parameters *keyfile*, *certfile*, *ca_certs* or *ciphers* are set, then | ||
| the values are passed to :meth:`SSLContext.load_cert_chain`, | ||
| :meth:`SSLContext.load_verify_locations`, and | ||
| :meth:`SSLContext.set_ciphers`. | ||
|
|
||
| The arguments *server_side*, *do_handshake_on_connect*, and | ||
| *suppress_ragged_eofs* have the same meaning as | ||
| :meth:`SSLContext.wrap_socket`. | ||
|
|
||
| .. deprecated:: 3.7 | ||
|
|
||
| Since Python 3.2 and 2.7.9, it is recommended to use the | ||
| :meth:`SSLContext.wrap_socket` instead of :func:`wrap_socket`. The | ||
| top-level function is limited and creates an insecure client socket | ||
| without server name indication or hostname matching. | ||
|
|
||
| Constants | ||
| ^^^^^^^^^ | ||
|
|
@@ -489,7 +460,7 @@ Constants | |
| .. data:: CERT_NONE | ||
|
|
||
| Possible value for :attr:`SSLContext.verify_mode`, or the ``cert_reqs`` | ||
| parameter to :func:`wrap_socket`. Except for :const:`PROTOCOL_TLS_CLIENT`, | ||
| parameter to :meth:`SSLContext.wrap_socket`. Except for :const:`PROTOCOL_TLS_CLIENT`, | ||
| it is the default mode. With client-side sockets, just about any | ||
| cert is accepted. Validation errors, such as untrusted or expired cert, | ||
| are ignored and do not abort the TLS/SSL handshake. | ||
|
|
@@ -502,7 +473,7 @@ Constants | |
| .. data:: CERT_OPTIONAL | ||
|
|
||
| Possible value for :attr:`SSLContext.verify_mode`, or the ``cert_reqs`` | ||
| parameter to :func:`wrap_socket`. In client mode, :const:`CERT_OPTIONAL` | ||
| parameter to :meth:`SSLContext.wrap_socket`. In client mode, :const:`CERT_OPTIONAL` | ||
| has the same meaning as :const:`CERT_REQUIRED`. It is recommended to | ||
| use :const:`CERT_REQUIRED` for client-side sockets instead. | ||
|
|
||
|
|
@@ -514,12 +485,12 @@ Constants | |
|
|
||
| Use of this setting requires a valid set of CA certificates to | ||
| be passed, either to :meth:`SSLContext.load_verify_locations` or as a | ||
| value of the ``ca_certs`` parameter to :func:`wrap_socket`. | ||
| value of the ``ca_certs`` parameter to :meth:`SSLContext.wrap_socket`. | ||
|
vstinner marked this conversation as resolved.
Outdated
|
||
|
|
||
| .. data:: CERT_REQUIRED | ||
|
|
||
| Possible value for :attr:`SSLContext.verify_mode`, or the ``cert_reqs`` | ||
| parameter to :func:`wrap_socket`. In this mode, certificates are | ||
| parameter to :meth:`SSLContext.wrap_socket`. In this mode, certificates are | ||
| required from the other side of the socket connection; an :class:`SSLError` | ||
| will be raised if no certificate is provided, or if its validation fails. | ||
| This mode is **not** sufficient to verify a certificate in client mode as | ||
|
|
@@ -534,7 +505,7 @@ Constants | |
|
|
||
| Use of this setting requires a valid set of CA certificates to | ||
| be passed, either to :meth:`SSLContext.load_verify_locations` or as a | ||
| value of the ``ca_certs`` parameter to :func:`wrap_socket`. | ||
| value of the ``ca_certs`` parameter to :meth:`SSLContext.wrap_socket`. | ||
|
|
||
| .. class:: VerifyMode | ||
|
|
||
|
|
@@ -1328,7 +1299,7 @@ SSL sockets also have the following additional methods and attributes: | |
| .. attribute:: SSLSocket.context | ||
|
|
||
| The :class:`SSLContext` object this SSL socket is tied to. If the SSL | ||
| socket was created using the deprecated :func:`wrap_socket` function | ||
| socket was created using the deprecated :meth:`SSLContext.wrap_socket` function | ||
| (rather than :meth:`SSLContext.wrap_socket`), this is a custom context | ||
| object created for this SSL socket. | ||
|
|
||
|
|
@@ -2086,7 +2057,7 @@ Combined key and certificate | |
|
|
||
| Often the private key is stored in the same file as the certificate; in this | ||
| case, only the ``certfile`` parameter to :meth:`SSLContext.load_cert_chain` | ||
| and :func:`wrap_socket` needs to be passed. If the private key is stored | ||
| and :meth:`SSLContext.wrap_socket` needs to be passed. If the private key is stored | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
vstinner marked this conversation as resolved.
Outdated
|
||
| with the certificate, it should come before the first certificate in | ||
| the certificate chain:: | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.