Skip to content

Commit

Permalink
check for NULL ca bundle
Browse files Browse the repository at this point in the history
win32 fixes
  • Loading branch information
ekoby committed Sep 29, 2023
1 parent fc74411 commit 1844318
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static int load_config_file(const char *filename, ziti_config *cfg) {
free(config);
return ZITI_INVALID_CONFIG;
}
cfg->cfg_source = realpath(filename, NULL);
cfg->cfg_source = strdup(filename);
free(config);
return ZITI_OK;
}
Expand Down
12 changes: 9 additions & 3 deletions library/ziti.c
Original file line number Diff line number Diff line change
Expand Up @@ -1805,9 +1805,15 @@ int ziti_context_init(ziti_context *ztx, const ziti_config *config) {

ziti_context ctx = calloc(1, sizeof(*ctx));

if (strncmp(config->id.ca, "file://", strlen("file://")) == 0) {
char *cfg_ca = config->id.ca;
if (cfg_ca == NULL) {
ZITI_LOG(WARN, "config is missing CA bundle");
cfg_ca = "";
}

if (strncmp(cfg_ca, "file://", strlen("file://")) == 0) {
struct tlsuv_url_s url;
if (tlsuv_parse_url(&url, config->id.ca) != 0) {
if (tlsuv_parse_url(&url, cfg_ca) != 0) {
ZITI_LOG(ERROR, "invalid CA bundle reference[]");
return ZITI_INVALID_CONFIG;
}
Expand All @@ -1820,7 +1826,7 @@ int ziti_context_init(ziti_context *ztx, const ziti_config *config) {
ctx->config.id.ca = ca;
}
} else {
ctx->config.id.ca = strdup(config->id.ca);
ctx->config.id.ca = strdup(cfg_ca);
}

ctx->config.controller_url = strdup(config->controller_url);
Expand Down

0 comments on commit 1844318

Please sign in to comment.