2017-04-16 07:41:32 +01:00
|
|
|
:mod:`ussl` -- SSL/TLS module
|
|
|
|
=============================
|
2015-10-20 14:04:55 +01:00
|
|
|
|
|
|
|
.. module:: ussl
|
|
|
|
:synopsis: TLS/SSL wrapper for socket objects
|
|
|
|
|
2017-07-02 13:37:31 +01:00
|
|
|
|see_cpython_module| :mod:`python:ssl`.
|
|
|
|
|
2017-04-16 07:41:32 +01: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 14:04:55 +01:00
|
|
|
|
2017-04-16 07:41:32 +01:00
|
|
|
Functions
|
|
|
|
---------
|
2015-10-20 14:04:55 +01:00
|
|
|
|
2017-10-30 16:03:54 +00:00
|
|
|
.. function:: ussl.wrap_socket(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=CERT_NONE, ca_certs=None)
|
2015-10-20 14:04:55 +01:00
|
|
|
|
2017-12-04 16:36:20 +00:00
|
|
|
Takes a `stream` *sock* (usually usocket.socket instance of ``SOCK_STREAM`` type),
|
2017-04-16 07:41:32 +01:00
|
|
|
and returns an instance of ssl.SSLSocket, which wraps the underlying stream in
|
2017-12-04 16:36:20 +00:00
|
|
|
an SSL context. Returned object has the usual `stream` interface methods like
|
2018-03-15 04:50:51 +00: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 07:41:32 +01:00
|
|
|
server-side SSL socket should be created from a normal socket returned from
|
2018-03-15 04:50:51 +00:00
|
|
|
:meth:`~usocket.socket.accept()` on a non-SSL listening server socket.
|
2015-10-20 14:04:55 +01:00
|
|
|
|
2017-10-30 16:03:54 +00:00
|
|
|
Depending on the underlying module implementation in a particular
|
2020-06-04 02:38:45 +01:00
|
|
|
:term:`MicroPython port`, some or all keyword arguments above may be not supported.
|
2015-10-20 14:04:55 +01:00
|
|
|
|
2017-04-16 07:41:32 +01:00
|
|
|
.. warning::
|
2015-10-20 14:04:55 +01:00
|
|
|
|
2017-10-30 16:03:54 +00:00
|
|
|
Some implementations of ``ussl`` module do NOT validate server certificates,
|
2017-04-16 07:41:32 +01:00
|
|
|
which makes an SSL connection established prone to man-in-the-middle attacks.
|
2015-10-20 14:04:55 +01:00
|
|
|
|
2017-04-16 07:41:32 +01:00
|
|
|
Exceptions
|
|
|
|
----------
|
2015-10-20 15:24:25 +01:00
|
|
|
|
2017-04-16 07:41:32 +01:00
|
|
|
.. data:: ssl.SSLError
|
2015-10-20 15:24:25 +01:00
|
|
|
|
2017-04-16 07:41:32 +01:00
|
|
|
This exception does NOT exist. Instead its base class, OSError, is used.
|
2015-10-20 14:04:55 +01:00
|
|
|
|
2017-04-16 07:41:32 +01:00
|
|
|
Constants
|
|
|
|
---------
|
2015-10-20 14:04:55 +01:00
|
|
|
|
2017-10-30 16:03:54 +00:00
|
|
|
.. data:: ussl.CERT_NONE
|
|
|
|
ussl.CERT_OPTIONAL
|
|
|
|
ussl.CERT_REQUIRED
|
2015-10-21 21:52:36 +01:00
|
|
|
|
2017-06-29 22:34:52 +01:00
|
|
|
Supported values for *cert_reqs* parameter.
|