Skip to content

Commit 515e44e

Browse files
authored
Merge pull request #857 from openziti/ca-bundle-update
update bundle on TLS context
2 parents f1fb5f4 + b4a486c commit 515e44e

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

deps/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (NOT TARGET tlsuv)
99
else ()
1010
FetchContent_Declare(tlsuv
1111
GIT_REPOSITORY https://github.com/openziti/tlsuv.git
12-
GIT_TAG v0.33.10
12+
GIT_TAG v0.34.1
1313
)
1414
FetchContent_MakeAvailable(tlsuv)
1515
endif (tlsuv_DIR)

library/oidc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ static void free_auth_req(auth_req *req) {
337337
json_tokener_free(req->json_parser);
338338
req->json_parser = NULL;
339339
}
340+
FREE(req->id);
340341
free(req);
341342
}
342343

library/posture.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ static void send_posture_legacy(ziti_context ztx, model_list *send_prs) {
627627
ZTX_LOG(TRACE, "bulk posture response: %s", body);
628628

629629
ziti_pr_post_bulk(ztx_get_controller(ztx), body, body_len, ziti_pr_post_bulk_cb, ztx);
630+
free(body);
630631
string_buf_free(&buf);
631632
}
632633

@@ -1066,8 +1067,8 @@ void ziti_endpoint_state_change(ziti_context ztx, bool woken, bool unlocked) {
10661067
size_t obj_len;
10671068

10681069
char *obj = ziti_pr_endpoint_state_req_to_json(&state_req, 0, &obj_len);
1069-
10701070
ziti_pr_post(ztx_get_controller(ztx), obj, obj_len, ziti_endpoint_state_pr_cb, ztx);
1071+
FREE(obj);
10711072
} else {
10721073
ZTX_LOG(INFO, "endpoint state change reported, but no reason to send data: woken[%s] unlocked[%s]", woken ? "TRUE":"FALSE", unlocked ? "TRUE":"FALSE");
10731074
}

library/ziti.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,23 +1583,15 @@ static void ca_bundle_cb(char *pkcs7, const ziti_error *err, void *ctx) {
15831583
goto error;
15841584
}
15851585

1586-
if (ztx->config.id.ca && strcmp(new_pem, ztx->config.id.ca) != 0) {
1586+
if (ztx->config.id.ca == NULL || strcmp(new_pem, ztx->config.id.ca) != 0) {
1587+
ztx->tlsCtx->set_ca_bundle(ztx->tlsCtx, new_pem, strlen(new_pem));
15871588
char *old_ca = (char*)ztx->config.id.ca;
1589+
free(old_ca);
1590+
15881591
ztx->config.id.ca = new_pem;
1592+
new_pem = NULL;
15891593

1590-
tls_context *new_tls = NULL;
1591-
tls_context *old_tls = ztx->tlsCtx;
1592-
if (load_tls(&ztx->config, &new_tls, &ztx->id_creds) == 0) {
1593-
ztx_config_update(ztx);
1594-
free(old_ca);
1595-
ztx->tlsCtx = new_tls;
1596-
tlsuv_http_set_ssl(ztx_get_controller(ztx)->client, ztx->tlsCtx);
1597-
new_pem = NULL; // owned by ztx->config
1598-
old_tls->free_ctx(old_tls);
1599-
} else {
1600-
ztx->config.id.ca = old_ca;
1601-
ZITI_LOG(ERROR, "failed to create TLS context with updated CA bundle");
1602-
}
1594+
ztx_config_update(ztx);
16031595
}
16041596
} else {
16051597
ZITI_LOG(ERROR, "failed to get CA bundle from controller: %s", err->message);

library/ziti_ctrl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,8 @@ void ziti_pr_post(ziti_controller *ctrl, char *body, size_t body_len,
10681068

10691069
tlsuv_http_req_t *req = start_request(ctrl->client, "POST", "/posture-response", ctrl_resp_cb, resp);
10701070
tlsuv_http_req_header(req, "Content-Type", "application/json");
1071-
tlsuv_http_req_data(req, body, body_len, free_body_cb);
1071+
char *copy = strdup(body);
1072+
tlsuv_http_req_data(req, copy, body_len, free_body_cb);
10721073
}
10731074

10741075
void ziti_pr_post_bulk(ziti_controller *ctrl, char *body, size_t body_len,
@@ -1079,7 +1080,8 @@ void ziti_pr_post_bulk(ziti_controller *ctrl, char *body, size_t body_len,
10791080

10801081
tlsuv_http_req_t *req = start_request(ctrl->client, "POST", "/posture-response-bulk", ctrl_resp_cb, resp);
10811082
tlsuv_http_req_header(req, "Content-Type", "application/json");
1082-
tlsuv_http_req_data(req, body, body_len, free_body_cb);
1083+
char *copy = strdup(body);
1084+
tlsuv_http_req_data(req, copy, body_len, free_body_cb);
10831085
}
10841086

10851087
static void ctrl_paging_req(struct ctrl_resp *resp) {

0 commit comments

Comments
 (0)