Commit Graph

53 Commits

Author SHA1 Message Date
Euripedes Rocha
faa368a612 [tcp_transport] Fix initialition of transport
- Foundation was initialized only for SSL.
- Removed base from list.
- Changed SSL and TCP initialition.
- Clean of state data structures.
2022-09-12 11:49:25 +02:00
Mahavir Jain
5355ba06f1 transport_ssl: use return value from close for non-TLS case 2022-02-10 13:03:32 +05:30
Dániel Buga
9e892fbf46 Set success when closing socket
Closes https://github.com/espressif/esp-idf/pull/8337
Closes IDFGH-6709
2022-02-10 13:02:58 +05:30
Axel Lin
9d07e89f13 tcp_transport: Fix NULL pointer dereference in esp_transport_esp_tls_create
Add missing NULL checking to prevent NULL pointer dereference if calloc failed.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
2021-09-08 11:04:08 +08:00
liuhan
37e08d38a4 tls: Modify tls optimize both mbedtls and wolfssl 2021-06-28 10:22:24 +08:00
David Cermak
1a7e75036b tcp_transport: Fix to cleanup esp-tls context on close 2021-06-20 21:21:22 +02:00
David Cermak
f68d7d7023 esp_tls: Renamed public API to indicate the Plain TCP connection
Also added parameter checks if used from as a public API
and updated the `is_plein_tcp` description that it's possible to connect
directly using plain tcp transport with the new API.
2021-05-25 10:55:50 +02:00
David Cermak
38fd2ed10b tcp_transport: Rename common tcp/ssl internals to base-transport
Also uses INVALID_SOCKET macro instead of magic number (-1)
2021-05-25 10:55:45 +02:00
David Cermak
6cf077169e tcp_transport: Rework test to split test code and use fixtures 2021-05-25 07:04:02 +02:00
David Cermak
f249ddd9ae esp_transport: Use tcp_connect from esp_tls for plain TCP
so we don't have to allocate esp_tls structure (~2KB) to save heap when using plain TCP connection

Closes https://github.com/espressif/esp-idf/issues/6940
2021-05-25 07:04:02 +02:00
Axel Lin
aa333d4ab9 tcp_transport: Fix NULL pointer dereference if esp_transport_init returns NULL
Add missing NULL test for esp_transport_init() call.
Otherwise, it will hit NULL pointer dereference when assign t->_get_socket.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
2021-05-03 15:46:59 +08:00
Aditya Patwardhan
d74f7d2d04 tcp_transport: Add option to enable crt_bundle for SSL connection 2021-04-07 05:31:21 +00:00
David Cermak
86bcd9fc21 tcp_transport: Fix error handling of esp_tls_init() 2021-03-24 12:24:23 +00:00
yuanjm
c62cbd1254 transport: Support bind socket to specified interface in transport and esp-tls 2021-03-10 02:19:29 +00:00
David Cermak
1fa0db8d44 tcp_transport: Allow for using transport independently from list
For compatibility reasons, support also transports separately if the transport is used
before attaching to parent list. In this case we create an internal context which is
independent on the foundation transport and used preferably
2021-02-16 09:01:35 +01:00
David Cermak
6b318fe583 esp_tls: Updated connection method to use non-blocking connect
For better control over connection timeouts
To be in line with former tcp_transport, as esp-tls is not used for
plain tcp transports
2021-02-16 09:00:43 +01:00
David Cermak
2c28ffffee tcp_transport/esp_tls: Use common TCP transport to reduce code duplication
For high level review of the changes.
2021-02-16 09:00:43 +01:00
David Cermak
391d7bf271 tcp_transport: Add TCP transport connection errors
Transport's error_handle is used to capture different types of errors
including esp_err_t from esp-tls and socket/system errors.
This change adds the following error codes for TCP transport:
* connection closed by a FIN flag (clean closure from server)
* DNS resolution problem
* connection timeout
These errors are already defined in esp-tls component and since this
component will be used in the future for both TCP and SSL transport, we
currently report these issues in transport::error_handle::esp_tls_last_error
of standard esp error type (esp_err_t)

Closes https://github.com/espressif/esp-mqtt/issues/182
2021-02-16 09:00:43 +01:00
aditi_lonkar
7bf205162c tcp_transport: Fix some memory leak issues by coverity static analyzer. 2021-01-25 03:37:47 +00:00
yuanjm
044c3e3e74 Modify esp-tls and tcp_transport to support keep alive for tcp and ssl connection
Closes IDFGH-4543
2021-01-22 06:56:28 +00:00
David Cermak
ce519ee783 tcp_transport: Extend transport error storage for socket error
Everytime we report error and log errno, we also capture the actual
errno to an internal storage so that user application can retrieve
its value.
2020-11-12 12:46:22 +00:00
Angus Gratton
66fb5a29bb Whitespace: Automated whitespace fixes (large commit)
Apply the pre-commit hook whitespace fixes to all files in the repo.

(Line endings, blank lines at end of file, trailing whitespace)
2020-11-11 07:36:35 +00:00
Aditya Patwardhan
91b88acaec tcp_transport: Added required API to support Digital Signature for SSL 2020-09-22 18:31:31 +05:30
xutao
bd2daccb22 transport: fix transport ssl blocking
In SSL mode, if `esp_transport_poll_read` function is used, the cache data in mebdtls will be blocked
2020-09-02 07:01:01 +00:00
David Cermak
5e9f8b52e7 tcp_transport: Added internal API for underlying socket, used for custom select on connection end for WS
Internal tcp_transport functions could now use custom socket operations.
This is used for WebSocket transport, when we typically wait for clean
connection closure, i.e. selecting for read/error with expected errno or
recv size=0 while socket readable (=connection terminated by FIN flag)
2020-08-18 06:42:22 +00:00
Aditya Patwardhan
423e600d46 secure_element: atecc608_ecdsa example
* Replaced crypotoauthlib with esp-cryptoauthlib
* Added menuconfig option for esp-tls about using HSM
* Added error codes for HSM in esp-tls,
* Added support to select different type of ATECC608A chips
* Added README, updated docs
* tcp_transport: Added option to enable secure_element for ssl

Closes https://github.com/espressif/esp-idf/issues/4432
2020-05-21 13:08:30 +05:30
David Cermak
6182e6f303 tcp_transport: close to return error only for socket error or invalid args
Closes https://github.com/espressif/esp-idf/issues/4872
2020-05-05 15:53:09 +02:00
Mahavir Jain
49ce8d3fe5 transport_ssl: reset state on connection closure
For url redirection cases (HTTP status 301/302), internal
transport ssl connection state must be reinitialized for
successful (new) connection on updated url.

Closes https://github.com/espressif/esp-idf/issues/4598
2020-04-15 15:22:32 +05:30
David Cermak
aa3b1da384 esp_tls: added connection timeout to esp_tls_conn_new_sync() 2020-01-16 07:32:19 +00:00
David Cermak
b69ac4448e tcp_transport: added API for client-key password 2020-01-06 21:16:24 +00:00
Angus Gratton
412b202741 Merge branch 'bugfix/ws_client_fix_wait_forever_timeout' into 'master'
ws_client: fix handling timeouts by websocket client.

Closes IDFGH-2161

See merge request espressif/esp-idf!6683
2019-11-20 07:44:25 +08:00
David Cermak
e1f982921a ws_client: fix handling timeouts by websocket client.
tcp-transport component did not support wait forever. this update uses value of -1 to request this state.
websocket client uses timeouts in RTOS ticks. fixed recalculation to ms (including special value of -1) to use correctly tcp-transport component

Closes https://github.com/espressif/esp-idf/issues/4316
2019-11-18 10:59:41 +00:00
Marius Vikhammer
ed85046138 tcp_transport: added functionality for using ALPN with SSL
Closes IDF-1160
2019-11-13 11:33:13 +08:00
Liu Han
3ca07b3e70 fix(transport): Fix a bug of the connection whether be active or not by timeout option when the select function return a correct value. 2019-09-12 13:55:47 +08:00
David Cermak
f3d6a34e7d esp_tls: enable psk verification mode, added mqtt example using psk authentication 2019-08-07 14:27:40 +10:00
Angus Gratton
7ef5fa8a0a Merge branch 'feature/transport_support_der_certs' into 'master'
tcp transport ssl DER-support

See merge request espressif/esp-idf!5627
2019-08-05 09:52:08 +08:00
David Cermak
25dd5e39af esp-tls: Naming variables refering to certificates and keys in a neutral way to suggest that both PEM and DER format could be used, added comments descibing important details about using these formats 2019-08-02 09:25:16 +02:00
Henning Fleddermann
546b625433 add _der variants for esp_transport_ssl_set_(client_cert|client_key|cert_data)
Signed-off-by: David Cermak <cermak@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/3783
2019-08-02 09:25:16 +02:00
Anton Maklakov
afbaf74007 tools: Mass fixing of empty prototypes (for -Wstrict-prototypes) 2019-08-01 16:28:56 +07:00
David Cermak
587739391c esp-tls: extending error handle to contain error descriptors with last mbedtls failure and latest certificate verification result flags, reworked tcp_transport to use this error handle 2019-07-04 20:55:10 +02:00
David Cermak
2972f96982 esp-tls: capturing specific errors to be available in tcp_transport and then in application code 2019-07-04 20:55:10 +02:00
Jitin George
c536c8fa5f tcp_transport: Add API to allow skipping of certificate CN validation 2019-06-25 23:41:33 +00:00
Tuan
2a2d932cfe esp_websocket_client: Add websocket client component
Closes https://github.com/espressif/esp-idf/issues/2829
2019-06-20 15:37:40 +08:00
Mahavir Jain
27e00cf7aa esp_http_client: add support for using certs from global ca store
Closes https://github.com/espressif/esp-idf/issues/3062
2019-02-27 14:19:06 +05:30
rustyx
053219283d Handle esp_tls_conn_read disconnection in ssl_read. Fixes #2805
Closes https://github.com/espressif/esp-idf/pull/2967
2019-01-23 16:47:23 +05:30
Jitin George
e2ae69f6fb Minor Bugfixes in esp_http_client, tcp_transport and simple_ota_example 2019-01-07 16:33:41 +08:00
David Cermak
0cdb33c9dd mqtt: ssl mutual authentication example added per PR from github, corrected cmake build, updated per idf style
Merges https://github.com/espressif/esp-idf/pull/2490
2018-10-30 08:04:09 +01:00
Riccardo Binetti
9ce8e1e5a1 transport_ssl: add support for mutual SSL authentication
Signed-off-by: David Cermak <cermak@espressif.com>
2018-10-30 08:04:09 +01:00
David Cermak
0d4f5cc495 tcp_transport: transport set handle refactoring, web socket client name updated 2018-10-02 15:19:46 +02:00
David Cermak
e02225cc07 tcp_transport: renamed possibly generic function names to be esp_ prefixed and not to colide with user namespace 2018-10-02 14:16:48 +02:00