From 0a48ceec41121eb75de4fb109a2cf2ff802e05de Mon Sep 17 00:00:00 2001 From: "rohit.patil" Date: Wed, 25 Mar 2026 15:13:54 +0530 Subject: [PATCH] coap_net: skip Content-Format check for OSCORE FETCH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a FETCH request is OSCORE-protected the Content-Format option is an inner (encrypted) option per RFC 8613 §4.1.3.1 and is legitimately absent from the outer CoAP message. The existing RFC 8132 §2.3.1 check unconditionally rejects such requests with 4.15 (Unsupported Content-Format) even when COAP_OSCORE_SUPPORT is disabled and the application uses its own OSCORE stack. Only enforce the Content-Format presence rule when no OSCORE option is present in the outer request. Fixes: https://github.com/obgm/libcoap/issues/1936 --- src/coap_net.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/coap_net.c b/src/coap_net.c index 1b3b18cf..01b9483a 100644 --- a/src/coap_net.c +++ b/src/coap_net.c @@ -3859,11 +3859,13 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu goto fail_response; } if (pdu->code == COAP_REQUEST_CODE_FETCH) { - opt = coap_check_option(pdu, COAP_OPTION_CONTENT_FORMAT, &opt_iter); - if (opt == NULL) { - /* RFC 8132 2.3.1 */ - resp = 415; - goto fail_response; + if (coap_check_option(pdu, COAP_OPTION_OSCORE, &opt_iter) == NULL) { + opt = coap_check_option(pdu, COAP_OPTION_CONTENT_FORMAT, &opt_iter); + if (opt == NULL) { + /* RFC 8132 2.3.1 */ + resp = 415; + goto fail_response; + } } } if (context->mcast_per_resource &&