Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement TLS for Ethernet #6535

Closed
JetForMe opened this issue Jun 30, 2022 · 7 comments
Closed

Implement TLS for Ethernet #6535

JetForMe opened this issue Jun 30, 2022 · 7 comments

Comments

@JetForMe
Copy link

@ladyada said I should open a ticket here. I'd like to work on TLS support for Ethernet (e.g. Wiznet 5500). I have a great deal of general software development experience, but not a ton of Python, and very little knowledge of the micropython/CircuitPython networking stack internals.

If I could get some guidance from someone with more knowledge of the network stack, I could make significant progress.

Ideally, we should be able to make things like TSL/SSL support common to both WiFi and Ethernet (and any other underlying transport).

@tannewt tannewt added this to the Long term milestone Jun 30, 2022
@tannewt
Copy link
Member

tannewt commented Jun 30, 2022

Adding SSL support would be great! You are using the Python Wiznet driver now right?

The MicroPython and CircuitPython network approaches are a bit different now. The CP APIs were designed to support Python-only drivers but MP took a more CPython approach where the OS manages it.

One place to start is the ssl module from Python. It is used to wrap sockets. We have a subset of the API here: https://github.com/adafruit/circuitpython/tree/main/shared-bindings/ssl I think we can continue to use this model.

Right now the only implementation we have punts to the ESP-IDF for everything. Having port-agnostic TLS would be awesome though. That'd help in supporting the new Pico W too.

Here's how I'd suggest starting:

  1. Join the Discord chat for #circuitpython-dev where we can help in real-time.
  2. Get CP building: https://learn.adafruit.com/building-circuitpython
  3. Figure out what sockets we need to wrap and how that impacts the ssl module implementation.

@victorallume
Copy link

I'm trying to implement something similar in micropython (on ESP32, or wherever); namely getting SSL working on the pure-python wiznet driver (which was backported from circuitpython). Findings so far:

  • On an ESP32, the SSL library is MBedTLS running on the ESP-IDF. There are micropython and circuitpython bindings to that library, but that have diverged (though there will likely be an SSL context manager coming to micropython soon, so might re-converge at some stage)
  • The socket class provided by adafruit_wiznet5k_socket.py doesn't implement the streaming interface that the SSL module requires; in particular, it needs to inherit from io.IOBase and provide methods for read(), write() and ioctl() (the wiznet socket library only provides recv and send)
  • Just implementing the above doesn't work

While I'm trying to get this going on micropython, I'm happy to share in both directions

@nabber00
Copy link

See #2202

@ronpang
Copy link

ronpang commented Jun 20, 2023

Hi Everyone, I'm Ron from WIZnet HK.

After viewing these issue, I wanted to try to modify our socket section that allows the SSL function could work on our PICO board in circuitpython.

Will there be anyone could help me to give some guideline to work on this development?

Also, I had join the discord chat as well. Which hastag section that I bring up this topic?

@tannewt
Copy link
Member

tannewt commented Jun 20, 2023

Will there be anyone could help me to give some guideline to work on this development?

I don't know a lot about SSL but can help guide you in CP. @victorallume's comment seems on the right track. The goal would to to have the native ssl module wrap a non-ssl, Python-only socket object.

Also, I had join the discord chat as well. Which hastag section that I bring up this topic?

#circuitpython-dev is the best place to discuss modifying the C core of CircuitPython. Note that most of us are in the US and are unlikely to be online during our night.

@ronpang
Copy link

ronpang commented Jun 29, 2023

@tannewt

Thanks for your explanation. I think I need to study more about the steaming interface to make it happen.

@victorallume

I found that our HQ members had made SSL/TLS in MQTT for micropython. Maybe it would help.

https://github.com/renakim/W5100S-EVB-Pico-Micropython/tree/main/examples/AWS

https://github.com/renakim/W5100S-EVB-Pico-Micropython/tree/main/examples/Azure

@anecdata
Copy link
Member

Implemented by #8954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants