2017-04-16 02:41:32 -04:00
|
|
|
:mod:`ussl` -- SSL/TLS module
|
|
|
|
=============================
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2018-02-20 20:34:59 -05:00
|
|
|
.. include:: ../templates/unsupported_in_circuitpython.inc
|
|
|
|
|
2015-10-20 09:04:55 -04:00
|
|
|
.. module:: ussl
|
|
|
|
:synopsis: TLS/SSL wrapper for socket objects
|
|
|
|
|
2018-02-20 20:34:59 -05:00
|
|
|
|see_cpython_module| :mod:`cpython:ssl`.
|
2017-07-02 08:37:31 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
This module provides access to Transport Layer Security (previously and
|
|
|
|
widely known as “Secure Sockets Layer”) encryption and peer authentication
|
|
|
|
facilities for network sockets, both client-side and server-side.
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
Functions
|
|
|
|
---------
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
.. function:: ssl.wrap_socket(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=CERT_NONE, ca_certs=None)
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-06-29 17:34:52 -04:00
|
|
|
Takes a stream *sock* (usually usocket.socket instance of ``SOCK_STREAM`` type),
|
2017-04-16 02:41:32 -04:00
|
|
|
and returns an instance of ssl.SSLSocket, which wraps the underlying stream in
|
|
|
|
an SSL context. Returned object has the usual stream interface methods like
|
2018-02-20 20:34:59 -05:00
|
|
|
``read()``, ``write()``, etc. In MicroPython, the returned object does not expose
|
|
|
|
socket interface and methods like ``recv()``, ``send()``. In particular, a
|
2017-04-16 02:41:32 -04:00
|
|
|
server-side SSL socket should be created from a normal socket returned from
|
|
|
|
`accept()` on a non-SSL listening server socket.
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
Depending on the underlying module implementation for a particular board,
|
|
|
|
some or all keyword arguments above may be not supported.
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
.. warning::
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
Some implementations of ``ssl`` module do NOT validate server certificates,
|
|
|
|
which makes an SSL connection established prone to man-in-the-middle attacks.
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
Exceptions
|
|
|
|
----------
|
2015-10-20 10:24:25 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
.. data:: ssl.SSLError
|
2015-10-20 10:24:25 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
This exception does NOT exist. Instead its base class, OSError, is used.
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
Constants
|
|
|
|
---------
|
2015-10-20 09:04:55 -04:00
|
|
|
|
2017-04-16 02:41:32 -04:00
|
|
|
.. data:: ssl.CERT_NONE
|
|
|
|
ssl.CERT_OPTIONAL
|
|
|
|
ssl.CERT_REQUIRED
|
2015-10-21 16:52:36 -04:00
|
|
|
|
2017-06-29 17:34:52 -04:00
|
|
|
Supported values for *cert_reqs* parameter.
|