Wrap a socket in SSL/TLS. Arguments: - sock: Socket to wrap - context: SSL context to use for the encrypted connection Returns: - sock: New, encrypted socket.
(sock, context, hostname)
| 283 | if _have_ssl: |
| 284 | |
| 285 | def _encrypt_on(sock, context, hostname): |
| 286 | """Wrap a socket in SSL/TLS. Arguments: |
| 287 | - sock: Socket to wrap |
| 288 | - context: SSL context to use for the encrypted connection |
| 289 | Returns: |
| 290 | - sock: New, encrypted socket. |
| 291 | """ |
| 292 | # Generate a default SSL context if none was passed. |
| 293 | if context is None: |
| 294 | context = ssl._create_stdlib_context() |
| 295 | return context.wrap_socket(sock, server_hostname=hostname) |
| 296 | |
| 297 | |
| 298 | # The classes themselves |
no test coverage detected