Build problem for echo client sample with (D)TLS

Hi,

I am trying to compile the sample 

  zephyr/samples/net/sockets/echo_client

from the v2.3.0-rc1 version for the Thingy91, with TLS support:

$ west build -b thingy91_nrf9160_ns -- -DOVERLAY_CONFIG=overlay-tls.conf

This does not build, see below for the output. When omitting the overlay for TLS, the build works. What do I have to change to make it work?

Thanks, Thomas

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client
-- Using NCS Toolchain 2.2.0 for building. (/home/tludwig/ncs/toolchains/v2.2.0/cmake)
-- Found Python3: /home/tludwig/ncs/toolchains/v2.2.0/usr/local/bin/python3 (found suitable exact version "3.8.10") found components: Interpreter
-- Cache files will be written to: /home/tludwig/.cache/zephyr
-- Zephyr version: 3.2.99 (/home/tludwig/ncs/v2.3.0-rc1/zephyr)
-- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
-- Board: thingy91_nrf9160_ns
-- Found host-tools: zephyr 0.15.2 (/home/tludwig/ncs/toolchains/v2.3.0-rc1/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.15.2 (/home/tludwig/ncs/toolchains/v2.3.0-rc1/opt/zephyr-sdk)
-- Found Dtc: /home/tludwig/ncs/toolchains/v2.2.0/usr/local/bin/dtc (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found BOARD.dts: /home/tludwig/ncs/v2.3.0-rc1/nrf/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns.dts
-- Generated zephyr.dts: /home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client/build/zephyr/dts.cmake

warning: MBEDTLS_SSL_MAX_CONTENT_LEN (defined at modules/mbedtls/Kconfig:69,
modules/mbedtls/Kconfig:69) was assigned the value '2048' but got the value ''. Check these
unsatisfied dependencies: ((MBEDTLS_BUILTIN && MBEDTLS) || (MBEDTLS_BUILTIN && MBEDTLS && 0)) (=n).
See docs.zephyrproject.org/.../kconfig.html and/or look
up MBEDTLS_SSL_MAX_CONTENT_LEN in the menuconfig/guiconfig interface. The Application Development
Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
might be helpful too.


warning: TEST_RANDOM_GENERATOR (defined at subsys/random/Kconfig:8) was assigned the value 'y' but
got the value 'n'. Check these unsatisfied dependencies: (!ENTROPY_HAS_DRIVER) (=n). See
docs.zephyrproject.org/.../kconfig.html and/or look up
TEST_RANDOM_GENERATOR in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.


warning: The choice symbol MBEDTLS_BUILTIN (defined at modules/mbedtls/Kconfig:27,
modules/mbedtls/Kconfig:27) was selected (set =y), but MBEDTLS_LIBRARY_NRF_SECURITY (defined at
/home/tludwig/ncs/v2.3.0-rc1/nrf/Kconfig.nrf:31) ended up as the choice selection. See
docs.zephyrproject.org/.../kconfig.html and/or look up
MBEDTLS_BUILTIN in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.


warning: Experimental symbol NET_SOCKETS_SOCKOPT_TLS is enabled.


warning: Experimental symbol NET_SOCKETS_ENABLE_DTLS is enabled.


warning: Experimental symbol NET_CONNECTION_MANAGER is enabled.


warning: MBEDTLS_DTLS (defined at modules/mbedtls/Kconfig.tls-generic:34, /home/tludwig/ncs/v2.3.0-rc1/nrfxlib/nrf_security/Kconfig:120, modules/mbedtls/Kconfig.tls-generic:34) has direct dependencies ((MBEDTLS_TLS_VERSION_1_1 || MBEDTLS_TLS_VERSION_1_2) && !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) && MBEDTLS_BUILTIN && MBEDTLS_CFG_FILE = "config-tls-generic.h" && MBEDTLS) || ((MBEDTLS_TLS_VERSION_1_2 || MBEDTLS_SSL_PROTO_TLS1_2) && !MBEDTLS_BUILTIN) || ((MBEDTLS_TLS_VERSION_1_1 || MBEDTLS_TLS_VERSION_1_2) && !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) && MBEDTLS_BUILTIN && MBEDTLS_CFG_FILE = "config-tls-generic.h" && MBEDTLS && 0) with value n, but is currently being y-selected by the following symbols:
- NET_SOCKETS_ENABLE_DTLS (defined at subsys/net/lib/sockets/Kconfig:99), with value y, direct dependencies NET_SOCKETS_SOCKOPT_TLS && NET_SOCKETS && NETWORKING (value: y), and select condition NET_NATIVE && NET_SOCKETS_SOCKOPT_TLS && NET_SOCKETS && NETWORKING (value: y)
Parsing /home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client/Kconfig
Loaded configuration '/home/tludwig/ncs/v2.3.0-rc1/nrf/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns_defconfig'
Merged configuration '/home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client/prj.conf'
Merged configuration '/home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client/overlay-tls.conf'

error: Aborting due to Kconfig warnings

CMake Error at /home/tludwig/ncs/v2.3.0-rc1/zephyr/cmake/modules/kconfig.cmake:328 (message):
command failed with return code: 1
Call Stack (most recent call first):
/home/tludwig/ncs/v2.3.0-rc1/nrf/cmake/modules/kconfig.cmake:29 (include)
/home/tludwig/ncs/v2.3.0-rc1/zephyr/cmake/modules/zephyr_default.cmake:108 (include)
/home/tludwig/ncs/v2.3.0-rc1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
/home/tludwig/ncs/v2.3.0-rc1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:5 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /home/tludwig/ncs/toolchains/v2.3.0-rc1/usr/local/bin/cmake -DWEST_PYTHON=/home/tludwig/ncs/toolchains/v2.3.0-rc1/usr/local/bin/python3.8 -B/home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client/build -GNinja -DBOARD=thingy91_nrf9160_ns -DOVERLAY_CONFIG=overlay-tls.conf -S/home/tludwig/ncs/v2.3.0-rc1/zephyr/samples/net/sockets/echo_client

  • From the wiki the link points to

    > Provide NO SCREENSHOTS, the capture files are required

    "Text" nor "pictures" contain the details, but the capture does.

    < 200ms between two Client_Hello, that's quite fast.

    > 26.614250327    server_iaddr   modem_iaddr    DTLSv1.2   144     Server Hello

    That seems to be the first retransmission, maybe, I miss the details of the capture to see.

    So please, try to provide a capture. Maybe the server logs also some more hints, why the Server Hello is retransmitted.

  • Thanks!

    I opened it in wireshark. Even with set PSK secret, wireshark doesn't decrypt the Finish. That may be caused be different PSK secret, than assumed.

    So, back to the cause of causes for failing PSK (which I may have excluded too fast):

    Your PSK secret for openssl is "01020304050607080901020304050607" (hexadecimal).

    Please copy your snipet, how you provide that to the modem.

    (See nRF9160 modem_key_mgmt_cmp returns -1 )

  • You got it. The PSK is provided as a binary array:

    static const unsigned char psk[] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7};

    If I instead provide the PSK as a string with hexadecimal encoding, just like for s_server, together with strlen(psk), it works.

    static const char* psk = "01020304050607080901020304050607";

    The funny thing is that, in the first case, OpenSSL s_server does not complain about non-matching ciphers (it does in other cases). Neither does my golang DTLS echo server complain (which is using Pion DTLS). And in my mbedtls example, providing the PSK as a binary array works fine.

    Thanks!

  • You're welcome.

    For the most (D)TLS implementations it a good idea, to test them good enough, if they fit for your usage. In my experience, Eclipse/Californium (java) and mbedTLS (C) are good choices for the server side. For the client I use Eclipse/tinydtls (C) and also mbedTLS (C) works well. The other implementations stick to some interpretations of RFC6347 4.2.8, which then cause easily trouble. You will need to make your own experience.

    If you run the device in a public network (this usually comes with ip-address changes on sleep/wakeups), you need either frequently handshakes, or RFC9146 (DTLS 1.2 CID). With that it's mainly Eclipse/Californium in the cloud and tinydtls or mbedTLS (newer version with CID support) on the device, which works pretty well.

Related