You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
48 lines
1.7 KiB
:mod:`ussl` -- SSL/TLS module
|
|
=============================
|
|
|
|
.. module:: ussl
|
|
:synopsis: TLS/SSL wrapper for socket objects
|
|
|
|
|see_cpython_module| :mod:`python:ssl`.
|
|
|
|
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.
|
|
|
|
Functions
|
|
---------
|
|
|
|
.. function:: ussl.wrap_socket(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=CERT_NONE, ca_certs=None)
|
|
|
|
Takes a `stream` *sock* (usually usocket.socket instance of ``SOCK_STREAM`` type),
|
|
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
|
|
``read()``, ``write()``, etc. In MicroPython, the returned object does not expose
|
|
socket interface and methods like ``recv()``, ``send()``. In particular, a
|
|
server-side SSL socket should be created from a normal socket returned from
|
|
:meth:`~usocket.socket.accept()` on a non-SSL listening server socket.
|
|
|
|
Depending on the underlying module implementation in a particular
|
|
:term:`MicroPython port`, some or all keyword arguments above may be not supported.
|
|
|
|
.. warning::
|
|
|
|
Some implementations of ``ussl`` module do NOT validate server certificates,
|
|
which makes an SSL connection established prone to man-in-the-middle attacks.
|
|
|
|
Exceptions
|
|
----------
|
|
|
|
.. data:: ssl.SSLError
|
|
|
|
This exception does NOT exist. Instead its base class, OSError, is used.
|
|
|
|
Constants
|
|
---------
|
|
|
|
.. data:: ussl.CERT_NONE
|
|
ussl.CERT_OPTIONAL
|
|
ussl.CERT_REQUIRED
|
|
|
|
Supported values for *cert_reqs* parameter.
|
|
|