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

SSL support #13

Open
lypanov opened this issue Apr 23, 2021 · 1 comment
Open

SSL support #13

lypanov opened this issue Apr 23, 2021 · 1 comment
Labels
hacktoberfest hacktoberfest

Comments

@lypanov
Copy link

lypanov commented Apr 23, 2021

I was wondering if any progress had been made yet on SSL support? Namely I just tried getting the nim_imap library working but getting horribly deep stack traces due to it's usage of wrapsocket -> nim's net lib -> openssl (ends up calling into dynlib to load up openssl dynamically I assume).

Any clue how I could fix this? I imagine I need to somehow replace the openssl wrapper? Would love to help!

@elcritch
Copy link
Owner

elcritch commented Apr 23, 2021

I haven't tried the Nim SSL wrappers. As you mention, they dynamically load openssl which isn't supported on the ESP32's. However, ESP32's do provide SSL in the ESP-IDF directly in ESP-TLS.

The most pragmatic approach would be to use the ESP32's native TLS library since it's specialized for embedded usage. You can use it directly by making a Nim wrapper of the C api. To use it with Nim's standard library you'd need to get the socket file descriptor created by the ESP-TLS library. It'd take a bit more work but would be much more usable.

To try and tie it into Nim's sockets, you'd need to use esp-tls to create a new TLS connection, then get the socket file descriptor. Looks like there's this esp-tls function:

 esp_err_t esp_tls_get_conn_sockfd(esp_tls_t *tls, int *sockfd)

Then figure out how to create a Nim Socket type using the file descriptor. Nim wraps socket file descriptors as the SocketHandle type. It looks like there's a proc in net to create a Nim socket wrapper. From that the rest should work with a bit of fiddling of the socket parameters.

@elcritch elcritch added the hacktoberfest hacktoberfest label Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants