Skip to content

Commit 8161d87

Browse files
committed
extmod/modtls_mbedtls: Documentation of SSLSession support.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
1 parent a798d2d commit 8161d87

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

docs/library/ssl.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ facilities for network sockets, both client-side and server-side.
1313
Functions
1414
---------
1515

16-
.. function:: ssl.wrap_socket(sock, server_side=False, key=None, cert=None, cert_reqs=CERT_NONE, cadata=None, server_hostname=None, do_handshake=True)
16+
.. function:: ssl.wrap_socket(sock, server_side=False, key=None, cert=None, cert_reqs=CERT_NONE, cadata=None, server_hostname=None, do_handshake=True, session=None)
1717

1818
Wrap the given *sock* and return a new wrapped-socket object. The implementation
1919
of this function is to first create an `SSLContext` and then call the `SSLContext.wrap_socket`
@@ -28,6 +28,9 @@ Functions
2828
- *cadata* is a bytes object containing the CA certificate chain (in DER format) that will
2929
validate the peer's certificate. Currently only a single DER-encoded certificate is supported.
3030

31+
- *session* allows a client socket to reuse a session by passing a SSLSession object
32+
previously retrieved from the ``session`` property of a wrapped-socket object.
33+
3134
Depending on the underlying module implementation in a particular
3235
:term:`MicroPython port`, some or all keyword arguments above may be not supported.
3336

@@ -66,7 +69,7 @@ class SSLContext
6669
Set the available ciphers for sockets created with this context. *ciphers* should be
6770
a list of strings in the `IANA cipher suite format <https://wiki.mozilla.org/Security/Cipher_Suites>`_ .
6871

69-
.. method:: SSLContext.wrap_socket(sock, *, server_side=False, do_handshake_on_connect=True, server_hostname=None)
72+
.. method:: SSLContext.wrap_socket(sock, *, server_side=False, do_handshake_on_connect=True, server_hostname=None, session=None)
7073

7174
Takes a `stream` *sock* (usually socket.socket instance of ``SOCK_STREAM`` type),
7275
and returns an instance of ssl.SSLSocket, wrapping the underlying stream.
@@ -89,6 +92,9 @@ class SSLContext
8992
server certificate. It also sets the name for Server Name Indication (SNI), allowing the server
9093
to present the proper certificate.
9194

95+
- *session* allows a client socket to reuse a session by passing a SSLSession object
96+
previously retrieved from the ``session`` property of a ssl.SSLSocket object.
97+
9298
.. warning::
9399

94100
Some implementations of ``ssl`` module do NOT validate server certificates,
@@ -110,6 +116,19 @@ class SSLContext
110116
`mpremote rtc --set <mpremote_command_rtc>` or ``ntptime``, and ``server_hostname``
111117
must be specified when on the client side.
112118

119+
class SSLSession
120+
----------------
121+
122+
.. class:: SSLSession(buf)
123+
124+
This constructor is a MicroPython extension to reconstruct a SSLSession object using
125+
a bytes object previously returned by the ``serialize`` method.
126+
127+
.. method:: SSLSession.serialize()
128+
129+
This function is a MicroPython extension to return a bytes object representing the
130+
session, allowing it to be stored and reconstructed at a later time.
131+
113132
Exceptions
114133
----------
115134

0 commit comments

Comments
 (0)