@@ -13,7 +13,7 @@ facilities for network sockets, both client-side and server-side.
13
13
Functions
14
14
---------
15
15
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 )
17
17
18
18
Wrap the given *sock * and return a new wrapped-socket object. The implementation
19
19
of this function is to first create an `SSLContext ` and then call the `SSLContext.wrap_socket `
@@ -28,6 +28,9 @@ Functions
28
28
- *cadata * is a bytes object containing the CA certificate chain (in DER format) that will
29
29
validate the peer's certificate. Currently only a single DER-encoded certificate is supported.
30
30
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
+
31
34
Depending on the underlying module implementation in a particular
32
35
:term: `MicroPython port `, some or all keyword arguments above may be not supported.
33
36
@@ -66,7 +69,7 @@ class SSLContext
66
69
Set the available ciphers for sockets created with this context. *ciphers * should be
67
70
a list of strings in the `IANA cipher suite format <https://wiki.mozilla.org/Security/Cipher_Suites >`_ .
68
71
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 )
70
73
71
74
Takes a `stream ` *sock * (usually socket.socket instance of ``SOCK_STREAM `` type),
72
75
and returns an instance of ssl.SSLSocket, wrapping the underlying stream.
@@ -89,6 +92,9 @@ class SSLContext
89
92
server certificate. It also sets the name for Server Name Indication (SNI), allowing the server
90
93
to present the proper certificate.
91
94
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
+
92
98
.. warning ::
93
99
94
100
Some implementations of ``ssl `` module do NOT validate server certificates,
@@ -110,6 +116,19 @@ class SSLContext
110
116
`mpremote rtc --set <mpremote_command_rtc> ` or ``ntptime ``, and ``server_hostname ``
111
117
must be specified when on the client side.
112
118
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
+
113
132
Exceptions
114
133
----------
115
134
0 commit comments