Skip to content

Conversation

@casaroli
Copy link

@casaroli casaroli commented Nov 21, 2025

Add some improvements to make secure coap work on Zephyr 4.3.0 with mbedtls (not using Zephyr TLS protocol options).

west build -p always -b pico_plus2/rp2350b/m33/w libcoap/examples/zephyr/client-src --extra-conf libcoap-mbedtls.conf

@mrdeep1
Copy link
Collaborator

mrdeep1 commented Nov 22, 2025

Thanks for raising and working on this.

Fixing the pre-commit required changes should fix the the CI pre-commit, documentation and distribution builds.

In terms of the zephyr build, I would prefer that the generic MbedTLS (and WolfSSL) library setup configuration files were kept within the libcoap/zephyr directory for anyone to easily use rather then being in the libcoap/examples/zephyr directory.

@casaroli
Copy link
Author

Thank you for you comments.

I would prefer that the generic MbedTLS (and WolfSSL) library setup configuration files were kept within the libcoap/zephyr directory for anyone to easily use rather then being in the libcoap/examples/zephyr directory

You mean the libcoap_mbedtls.conf? I moved it to the example directory because I believe this is "application configuration". I.e. if the application developer includes the libcoap_mbedtls.conf, then the application will have different build time configuration (include coaps support, mbedtls, etc).

In zephyr, the extra configuration file it is usually used (in other examples) as

build -p always -b <board> libcoap/examples/zephyr/client-src --extra-conf libcoap_mbedtls.conf

the config file is relative to the application directory. So I thought it was good idea to move it there, to simplify the west command on a standard Zephyr build.

What do you think?

I guess we could still move the file to zephyr and pass --extra-conf ../../../zephyr/libcoap_mbedtls to west if you like it better.

Or we could just enable mbedtls by default in Zephyr (i.e. move the stuff in libcoap_mbedtls.conf to prj.conf and push for a more secure world 😅

Or just keep it like I suggested so we can simplify the west command and harmonize with how usually application extra configs are handled in examples.

Whatever you prefer, I can update the documentation to match.

Add some improvements to make secure coap work on Zephyr 4.3.0
with mbedtls (not using Zephyr TLS protocol options).
@casaroli
Copy link
Author

I have applied the pre-commit and fixed the Makefile.

We now set the build options to zephyr, so we make use of the
internal mbedtl in zephyr, so we do not require a specific header
file anymore.
@casaroli
Copy link
Author

Ok this one is tricky. Zephyr mbedtls does not expose mbedtls_version_get_number. We can work around this by setting some dummy number here or wait for Zephyr to merge a PR to make it expose that function.

What do you think?

@mrdeep1
Copy link
Collaborator

mrdeep1 commented Nov 24, 2025

Zephyr mbedtls does not expose mbedtls_version_get_number()

Actually it does if MBEDTLS_VERSION_C is defined. This was one of the reasons for having zephyr/config-mbedtls-libcoap.h in the zephyr/ directory which you have deleted as it defines all the needed MBedTLS definitions to allow libcoap to work based on how MBedTLS is configured (via Kconfig and prj.conf).

That said, I am not a Zephyr expert and there may be better ways to do things.

@casaroli
Copy link
Author

Lets try this first: zephyrproject-rtos/zephyr#99923

Please, bear with me on this 😅

Thank you for your time.

@mrdeep1
Copy link
Collaborator

mrdeep1 commented Nov 25, 2025

Lets try this first: zephyrproject-rtos/zephyr#99923

The challenge here is that we can currently build for MBedTLS, but builds will fail if someone is using a release version of Zephyr that does not include this fix.

@casaroli
Copy link
Author

can we just set this value as unknown if zephyr version is too low?

what is the earliest zephyr version you want to support?

@mrdeep1
Copy link
Collaborator

mrdeep1 commented Dec 2, 2025

what is the earliest zephyr version you want to support?

Certainly base 4.3.0 version, and ideally a couple of versions earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants