Skip to content

Commit e7863ce

Browse files
committed
kconfig: support custom server certs
when a custom server address is set using CONFIG_GOLIOTH_COAP_HOST_URI, cmake compares the setting to the expected values for prod/dev and includes the server certificate automatically. This caused the build to fail when a custom address is selected because no certificate will be included in the build. add CONFIG_COAP_SERVER_CERT_PEM_LOCATION which may be set to the location of a server cert in PEM format. This is optional when using the addresses of the prod/dev server, but required for all other CONFIG_GOLIOTH_COAP_HOST_URI values. Signed-off-by: Mike Szczys <mike@golioth.io>
1 parent 2cc1421 commit e7863ce

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ config POUCH_GATEWAY_SERVER_CERT_MAX_LEN
2323
help
2424
Maximum length of server certificate.
2525

26+
config COAP_SERVER_CERT_PEM_LOCATION
27+
string "Custom CoAP Server Cert Location"
28+
default ""
29+
help
30+
31+
By default, the gateway build automatically includes a
32+
certificate for prod/dev when CONFIG_GOLIOTH_COAP_HOST_URI
33+
matches the known URI for either server. When a different URI
34+
is set (or a different server certificate is needed) this
35+
symbol must be set to the absolute location of the server cert
36+
PEM file.
37+
2638
config POUCH_GATEWAY_DOWNLINK_BLOCK_TIMEOUT
2739
int "Downlink timeout"
2840
default 10

lib/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ zephyr_library_link_libraries(mbedTLS)
1919

2020
zephyr_library_get_current_dir_lib_name(${ZEPHYR_BASE} lib_name)
2121

22-
if(CONFIG_GOLIOTH_COAP_HOST_URI STREQUAL "coaps://coap.golioth.io")
22+
if (NOT (CONFIG_COAP_SERVER_CERT_PEM_LOCATION STREQUAL ""))
23+
set(cert_name ${CONFIG_COAP_SERVER_CERT_PEM_LOCATION})
24+
elseif(CONFIG_GOLIOTH_COAP_HOST_URI STREQUAL "coaps://coap.golioth.io")
2325
set(cert_name "server-prod.pem")
2426
elseif(CONFIG_GOLIOTH_COAP_HOST_URI STREQUAL "coaps://coap.golioth.dev")
2527
set(cert_name "server-dev.pem")
28+
else()
29+
message(SEND_ERROR
30+
"Unable to find server certificate for CONFIG_GOLIOTH_COAP_HOST_URI value \
31+
(${CONFIG_GOLIOTH_COAP_HOST_URI}). Set CONFIG_COAP_SERVER_CERT_PEM_LOCATION to PEM file \
32+
location.
33+
")
2634
endif()
2735

2836
generate_inc_file_for_target(${lib_name}

0 commit comments

Comments
 (0)