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

  •  

    you may have noticed, that other also struggle with that. Maybe it's possible to improve the documentation. Why did you use the "binary" 

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

    approach?

    Did you read Modem key management ? Did you miss a PSK example there?

    Did you read something else? Did you use an (wrong?) example?

  • Good question. Looking around, I found the following things that take binary PSKs:

    - tls_credential_add() in Zephyr. An example is found in samples/net/sockets/echo_client

    - mbedtls_my_ssl_conf_psk()

    - Pion DTLS

    There are probably more such examples. So it is kind of natural to fall to do it the same way. Also I think it is a bit odd to require the hex format in a library. It looks like it is a thin wrapper around the AT command.

    Further, I did not find any example using in-modem PSK. There is the echo-client example in the Zephyr project but it uses tls_credentials_add(). And it does not compile for the nrf9160, which was the reason to open this issue.


    Suggestions:

    - Add a brief section about PSK key format requirements in the modem key mgmt documentation.

    - Add a check for non 0123456789abcdefABCDEF characters in modem_key_mgmt_write etc. when MODEM_KEY_MGMT_CRED_TYPE_PSK is being used. This is not 100% but will help in most cases.

    - Add an example of an echo client that uses in-modem DTLS.



    Regarding your comments on implementations supporting RFC6347 4.2.8 and CID, I will test this. It looks indeed like mbedtls or Eclipse/Californium would be more suitable than Pion DTLS for the server side.

  • Thanks!

    Yeah, if zephyr uses a a binary secret, then I guess, the missing docu for NCS modem library is the major cause of this pitfall. 

    Maybe someone from Nordic takes this and request to add an PSK secret example in order to improve the doku. 

Related