Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support single cert file and tls offloading #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ports/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ config MEMFAULT_HTTP_PERIODIC_UPLOAD_INTERVAL_SECS

endif # MEMFAULT_HTTP_ENABLE

config MEMFAULT_SINGLE_CERT_FILE
bool "use a single CA cert file with all certs inside it"
default n

config MEMFAULT_TLS_OFFLOAD
bool "TLS will be handled by offload"
default n

config MEMFAULT_EVENT_STORAGE_SIZE
int "Memfault Event Storage RAM Buffer Size"
default 1024
Expand Down
4 changes: 2 additions & 2 deletions ports/zephyr/common/memfault_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void prv_log_put_sync_string(const struct log_backend *const backend,
struct log_msg_ids src_level, uint32_t timestamp,
const char *fmt, va_list ap);
static void prv_log_panic(struct log_backend const *const backend);
static void prv_log_init(void);
static void prv_log_init(const struct log_backend * const backend);
static void prv_log_dropped(const struct log_backend *const backend, uint32_t cnt);
const struct log_backend_api log_backend_mflt_api = {
.put = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : prv_log_put,
Expand Down Expand Up @@ -115,7 +115,7 @@ static void prv_log_panic(struct log_backend const *const backend) {
}

// Zephyr will call our init function so we can establish some storage.
static void prv_log_init(void) {
static void prv_log_init(const struct log_backend * const backend) {
// static RAM storage where logs will be stored. Storage can be any size
// you want but you will want it to be able to hold at least a couple logs.
static uint8_t s_mflt_log_buf_storage[CONFIG_MEMFAULT_LOGGING_RAM_SIZE];
Expand Down
6 changes: 5 additions & 1 deletion ports/zephyr/common/memfault_platform_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "memfault/http/utils.h"
#include "memfault/panics/assert.h"

#if CONFIG_MBEDTLS
#if CONFIG_MBEDTLS && !CONFIG_MEMFAULT_TLS_OFFLOAD

// Sanity check that SNI extension is enabled when using Mbed TLS since as of 2.4 Zephyr doesn't
// enable it by default
Expand Down Expand Up @@ -115,10 +115,14 @@ static bool prv_send_data(const void *data, size_t data_len, void *ctx) {
}

static int prv_configure_tls_socket(int sock_fd, const char *host) {
#if CONFIG_MEMFAULT_SINGLE_CERT_FILE
const sec_tag_t sec_tag_opt[] = {kMemfaultRootCert_DigicertRootG2 };
#else
const sec_tag_t sec_tag_opt[] = {
kMemfaultRootCert_DigicertRootG2, kMemfaultRootCert_DigicertRootCa,
kMemfaultRootCert_CyberTrustRoot,
kMemfaultRootCert_AmazonRootCa1 };
#endif
int rv = setsockopt(sock_fd, SOL_TLS, TLS_SEC_TAG_LIST, sec_tag_opt, sizeof(sec_tag_opt));
if (rv != 0) {
return rv;
Expand Down