-
-
Notifications
You must be signed in to change notification settings - Fork 34
libraries/SocketWrapper: Fix agrs and improve error handling. #238
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
Conversation
iabdalkader
commented
Oct 30, 2025
- Fix socket timeout arg to use proper struct timeval
- Initialize addrinfo structs to prevent undefined behavior
- Add error checking for tls_credential_add() and setsockopt() calls
- Centralize socket cleanup in error path
- Change default return value to false for safer error handling
|
|
||
| Serial.println("Adding CA certificate..."); | ||
| // Add the ISRG Root X1 CA certificate | ||
| int ret = tls_credential_add(CA_CERTIFICATE_TAG, TLS_CREDENTIAL_CA_CERTIFICATE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add setCACert(const char *rootCA) to ZephyrSSLClient instead of using directly tls_credential_add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, connectSSL(const char *host, uint16_t port, char *ca_certificate_pem = nullptr) already accepts a cert blob, I should just use that instead.
2c9b100 to
b40ac44
Compare
| } | ||
|
|
||
| #if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS) | ||
| bool connectSSL(const char *host, uint16_t port, char *ca_certificate_pem = nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be const char *ca_certificate_pem together with
int connectSSL(const char *host, uint16_t port, const char *cert) in ZephyrClient.h and
int connect(const char *host, uint16_t port, const char *cert) in ZephyrSSLClient.h
or we need to cast the certificate blob
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Can you test it again?
- Fix socket timeout arg to use proper struct timeval - Initialize addrinfo structs to prevent undefined behavior - Add error checking for tls_credential_add() and setsockopt() calls - Centralize socket cleanup in error path - Change default return value to false for safer error handling - Change cert args to const Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
b40ac44 to
58160fc
Compare
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
58160fc to
7708097
Compare
|
works on
PR coming to enable MBEDTLS on GIGA R1 |