No Example for uasyncio SSL webserver
No example for uasyncio SSL webserver. Also couldn't find any on the internet. Looking for support.
extmod/uasyncio: Add ssl support to start_server.
here's example code starting a server with ssl.
(N.B. This code assumes the private key and certificate were previously created)
import ussl as ssl
basePath = "./"
with open(basePath + b"cert.key", "rb") as fd:
sslKey = fd.read()
with open(basePath + b"cert.cert", "rb") as fd:
sslCert = fd.read()
context = lambda sock: ssl.wrap_socket(sock, server_side=1, key=sslKey, cert=sslCert)
server = await asyncio.start_server(lambda r, w: handler(r, w)
, '0.0.0.0', 1965
, ssl=context)
I noticed there is a much more complete open PR to solve this issue in #5840 . My PR is just an attempt to solve the same issue just from a different angle.
@tve please review this.
This PR works in the unix port but it needs further changes for the esp32 port. In the esp32 port, I noticed that mbedtls wasn't working correctly (esp-idf seems to require a specific (older) micropython version. Or was it the reverse?) and thus decided to try axtls. I had a lot more success with axtls but it still required some code changes to make it work.
edit : I fixed the pasted example code formatting.