AsyncTCP icon indicating copy to clipboard operation
AsyncTCP copied to clipboard

mbed TLS client support, try 2

Open tve opened this issue 6 years ago • 30 comments

This is a tentative PR to replace #43 to account for the significant restructuring that was made on master since that PR. This still only has client-side TLS support. More testing is required before this can be considered for merging, I wanted to get this queued-up in case someone else is also working on this to avoid duplication of effort.

tve avatar Jun 25 '19 19:06 tve

@fremouw left a few comments. Also! Very important. You will notice that all calls to LwIP's tcp_* api are done through callbacks executed on LwIP's thread. In the ssl C code I notice that calls to LwIP are being made directly. This will cause a slew of issues and can not be merged as is.

me-no-dev avatar Jun 26 '19 21:06 me-no-dev

@tve thanks for taking care of rebasing this :)

me-no-dev avatar Jun 26 '19 21:06 me-no-dev

I dealt with the threading issue and added a pile of debug printfs in the process (they're all compiled out by default). The TLS connections now work, but I'd like to test it some more before you consider merging. However, I would appreciate a review first.

The main change that is not purely in #if ASYNC_TCP_SSL_ENABLED sections is the while loop you flagged earlier: https://github.com/me-no-dev/AsyncTCP/pull/48/files#diff-5c977e380a3eb2cac7b8881fd6fd9dcbR1012-R1054 I moved the _tcp_recvd call from inside tcp_mbedtls.c here and refactored a little the pb->next stuff. Should not change the semantics, but I did move a little code around.

tve avatar Aug 09 '19 19:08 tve

FYI, this has been working well for me. I see some crashes when closing/disconnecting but I believe this has to do with #59.

tve avatar Sep 01 '19 18:09 tve

@tve please rebase and also add an example or two so that code get's tested :)

me-no-dev avatar Sep 22 '19 19:09 me-no-dev

@tve please rebase and also add an example or two so that code get's tested :)

I did the rebase. Where do I find an example I can modify to use TLS?

tve avatar Sep 24 '19 21:09 tve

I fixed the Codacy issues, but now travis is throwing a fit and doesn't download some libraries....

tve avatar Sep 25 '19 23:09 tve

@tve I had a quick look at your PR. My suggestion is that you change the file extension of your C file from c to cpp. That way it will become a c++ file and you will be able to call the functions without having to add an extra proxy function.

C++ is a super set of C so the code should just compile with few changes.

matt123p avatar Sep 30 '19 06:09 matt123p

Thanks for the suggestion, sounds like a good idea!

tve avatar Sep 30 '19 15:09 tve

Checking in, how are things going? @tve did the merger of #59 help? I'm looking to use tls for an async client connection.

robert-alfaro avatar Dec 21 '19 05:12 robert-alfaro

@robert-alfaro my fork is working great for me. WRT getting it merged, I'm stuck on:

@tve please rebase and also add an example or two so that code get's tested :)

I did the rebase. Where do I find an example I can modify to use TLS?

OK, now there are conflicts, but I don't want to spend the time rebasing and fixing again unless there's a path for getting it merged...

tve avatar Dec 21 '19 07:12 tve

I think there no doubt we want this merged...@me-no-dev is busy, but I think can agree. If there is anything I can help with, please let me know.

robert-alfaro avatar Dec 21 '19 15:12 robert-alfaro

I'm all for examples, but there are none in this repo... Why the requirement before merging?

robert-alfaro avatar Dec 22 '19 17:12 robert-alfaro

Yup, that's where I stopped... Also, the codacity issues are b.s. They complain about any use of strlen and offer zero alternatives. It doesn't make sense to convert all the code to use String...

tve avatar Dec 22 '19 18:12 tve

Have you tried strnlen()? I think it's considered safe because you pass in the size (compared to strlen running until it finds a \0)

robert-alfaro avatar Jan 03 '20 08:01 robert-alfaro

Hey, great stuff @tve . I used this branch to test out TLS on https://github.com/marvinroger/async-mqtt-client and works great. I am also here to offer any help needed to merge this. I have one question to ask. I am getting constantly the following message when using this PR :

[E][AsyncTCP.cpp:1130] _poll(): 0x3ffcc15c != 0x3ffd1ccc

Besides the E, the stack behaves fine, so I am not sure why I get that.

Tried to look at the code but I am not understanding what's up. https://github.com/tve/AsyncTCP/blob/mbed-tls-try2/src/AsyncTCP.cpp#L1130

Any ideas ? thanks.

nemidiy avatar Jan 11 '20 14:01 nemidiy

@tve may I have permission to push to your branch?

robert-alfaro avatar Jan 20 '20 22:01 robert-alfaro

I've been busy elsewhere, need to get back to this... If you create a PR against my repo I'd be happy to pull it in. Just create a PR in github with tve/AsyncTCP : mbed-tls-try2 as base.

tve avatar Jan 20 '20 22:01 tve

I was trying to push straight to this PR branch..avoiding forking your forked repo.

robert-alfaro avatar Jan 20 '20 22:01 robert-alfaro

You should not need to create a new fork, you simply select my fork & branch in the github dialog to create a PR.

tve avatar Jan 20 '20 22:01 tve

Is this assuming I've forked the upstream repo? What I've done thus far is:

git clone [email protected]:me-no-dev/AsyncTCP.git
git fetch origin pull/48/head:pr/48
git checkout pr/48
<work>
<commit>
git push [email protected]:tve/AsyncTCP pr/48:mbed-tls-try2

and obviously the push will fail because permissions:

ERROR: Permission to tve/AsyncTCP.git denied to robert-alfaro.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

fwiw, changes so far are just change strlen to sizeof for pers[]. Then I could do the rebase/merge. The strlen for psk_ vars is the way it's done everywhere.

robert-alfaro avatar Jan 20 '20 23:01 robert-alfaro

Yes, I assumed you had a github account and had forked. Got a git patch?

tve avatar Jan 21 '20 00:01 tve

I conflated this project with another..I do have a fork under my work email on same github account. I'll have something for you.

robert-alfaro avatar Jan 21 '20 00:01 robert-alfaro

@me-no-dev bump

robert-alfaro avatar Feb 02 '20 21:02 robert-alfaro

What's the best way for a github noob to get this into my download of ESPAsyncWebServer and make it work in arduino code? I'm currently using a combination of AsyncWebServer and AsyncWiFiManager, is it going to be a direct file overwrite? Is there a readme on how to implement? Cheers! @tve @me-no-dev

paytah232 avatar Apr 07 '20 00:04 paytah232

What's the best way for a github noob to get this into my download of ESPAsyncWebServer and make it work in arduino code? I'm currently using a combination of AsyncWebServer and AsyncWiFiManager, is it going to be a direct file overwrite? Is there a readme on how to implement? Cheers! @tve @me-no-dev

Adding this into platformio.ini worked for me

lib_deps = AsyncTCP=https://github.com/tve/AsyncTCP/archive/mbed-tls-try2.zip async-mqtt-client=https://github.com/tve/async-mqtt-client/archive/master.zip

fransking avatar Apr 09 '20 17:04 fransking

is there any example to use this fork?

wachidsusilo avatar Jan 31 '21 23:01 wachidsusilo

What is the status of this, is this can be merged?

njourdane avatar Feb 12 '22 17:02 njourdane

What is there actually missing to merge these changes to add TLS client support?

MichaelUray avatar May 03 '22 23:05 MichaelUray

if we wait on this, it will never go through. It has been years now. There are not enough users on those platforms with the same interests!

podaen avatar Oct 20 '22 09:10 podaen