@@ -2416,7 +2416,7 @@ static coap_context_t* coap_context_from_cfg(struct config_file *cfg)
24162416 char * oscore_conf = NULL ;
24172417 char * oscore_seq_file = NULL ;
24182418
2419- if (cfg -> coap_oscore_conf ) {
2419+ if (cfg -> coap_oscore_conf && cfg -> coap_oscore_seq_file ) {
24202420 oscore_conf = fname_after_chroot (cfg -> coap_oscore_conf , cfg , 1 );
24212421
24222422 if (!oscore_conf ) {
@@ -2434,16 +2434,19 @@ static coap_context_t* coap_context_from_cfg(struct config_file *cfg)
24342434 }
24352435 }
24362436
2437- coap_context = doc_setup_server_context (
2438- (const uint8_t * )cfg -> coaps_psk , strlen (cfg -> coaps_psk ), cfg -> coaps_psk_id ,
2439- cfg -> ssl_service_key , cfg -> ssl_service_pem , NULL ,
2440- oscore_conf , oscore_seq_file );
2437+ if (cfg -> coaps_psk && cfg -> coaps_psk_id && cfg -> ssl_service_key && cfg -> ssl_service_pem ) {
2438+ coap_context = doc_setup_server_context (
2439+ (const uint8_t * )cfg -> coaps_psk , strlen (cfg -> coaps_psk ), cfg -> coaps_psk_id ,
2440+ cfg -> ssl_service_key , cfg -> ssl_service_pem , NULL ,
2441+ oscore_conf , oscore_seq_file );
2442+
2443+ if (!coap_context ) {
2444+ fatal_exit ("Unable to create CoAP server context for DoC." );
2445+ }
2446+ }
24412447
24422448 free (oscore_conf );
24432449 free (oscore_seq_file );
2444- if (!coap_context ) {
2445- fatal_exit ("Unable to create CoAP server context for DoC." );
2446- }
24472450
24482451 return coap_context ;
24492452}
0 commit comments