Replies: 2 comments 5 replies
-
For what it's worth I'm in the same boat. Oddly, I had TLS working in March 2023, but when I returned to this code in April it had stopped working. Would appreciate some input from the @zephyr team. The layers of abstraction make issues like this difficult to trace, and lack of meaningful documentation in key areas (like TLS) is stunning. |
Beta Was this translation helpful? Give feedback.
-
Okay so I figured out what the issue was on my end. It's rather simple, but not obvious anywhere in the docs. The problem is that a large number of issues will simply get marked in Zephyr as -22 (Invalid argument). So what you need to do is to enable debug output from the library itself, which would give you some sort of error code. Here's what you need to do:
#include <mbedtls/debug.h>
mbedtls_debug_set_threshold(DEBUG_LEVEL); Note that the debug level will vary from person to person, according to the beautiful comment in the function documentation: /**
* \brief Set the threshold error level to handle globally all debug output.
* Debug messages that have a level over the threshold value are
* discarded.
* (Default value: 0 = No debug )
*
* \param threshold threshold level of messages to filter on. Messages at a
* higher level will be discarded.
* - Debug levels
* - 0 No debug
* - 1 Error
* - 2 State change
* - 3 Informational
* - 4 Verbose
*/
void mbedtls_debug_set_threshold(int threshold);
For me personally, I was running into issues where I didn't have the right Kconfig settings enabled for the algorithms my certificates and keys were using, as well as the bulk encryption used/accepted by my remote POSIX end. Hope it helps :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm facing a problem after TLS credential setup, the socket I created cannot be connected, it throws the error number 22 - Invalid Argument which I have no idea where it comes from. My purpose with this code is to send a POST request to http host login.microsoftonline.com to get OAuth2.0 access token. Without TLS credential setup, it works perfectly fine but of course I would get redirect URL response due to missing credential to talk with port 443. But when I try setting TLS, it has error at
zsock_connect
function. This is my sample code, WiFi is already setup and connected.This is my ca_certificate.h file, the credential certificate I used which I took from login.microsoftonline.com, it is called DigiCert Global Root CA.
I have tried to include the .der file to directly get the data but it has a problem with handshake function so I decide to paste the whole block of certificate instead.
This is my prj.conf:
I have digged very deep in the source code of zephyr subsystem to find the source of error, turn on debug log, place serveral
printk()
to track the progress. I dig to TCP module, no problem or log error at all, it can send and receive data perfectly. But when I track the sockets.c module in zephyrproject/zephyr/subsys/net/lib/sockets, I place aprintk("%s %d\n", __func__, ret)
insideVTABLE_CALL(fn, sock, ...)
macro function like this:I saw this while loop run twice in the function
z_impl_zsock_connect
, the first attempt works perfectly with theret = 0
fromsock_connect_vmeth
as well aszsock_connect_ctx
and have no problem at all in the deeper nest of subsystem code, at this point, I'm 99% sure the socket is connected and ready to send the http client request. But then the second attempt pops up withret = -1
without any deeper execution, anderrno = 22
from nowhere, no log error, none of myprintk()
appears.Can anyone explain this situation. I'm really confused, I even tried swap to
google.com
host and the corresponding TLS certificate but still the same error. I'm extremely appriciate if anyone can help.Beta Was this translation helpful? Give feedback.
All reactions