Skip to content
Merged
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
1 change: 1 addition & 0 deletions inc_internal/internal_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ XX(identity, ziti_identity, none, identity, __VA_ARGS__) \
XX(posture_query_set, ziti_posture_query_set, array, postureQueries, __VA_ARGS__) \
XX(is_mfa_required, model_bool, none, isMfaRequired, __VA_ARGS__) \
XX(is_mfa_complete, model_bool, none, isMfaComplete, __VA_ARGS__) \
XX(is_cert_improper, model_bool, none, improperClientCertChain, __VA_ARGS__) \
XX(is_cert_extendable, model_bool, none, isCertExtendable, __VA_ARGS__) \
XX(cert_extend_requested, model_bool, none, isCertExtendRequested, __VA_ARGS__) \
XX(key_roll_requested, model_bool, none, isCertKeyRollRequested, __VA_ARGS__) \
Expand Down
19 changes: 15 additions & 4 deletions library/ziti.c
Original file line number Diff line number Diff line change
Expand Up @@ -2173,21 +2173,30 @@ static void api_session_cb(ziti_api_session *api_sess, const ziti_error *err, vo
}
}

// check if identity cert can and need to be extended
if (ztx->opts.cert_extension_window == 0 || ztx->id_creds.cert == NULL) {
if (ztx->id_creds.cert == NULL) {
goto done;
}

// it is a 3rd party cert, no need for the rest of checks
if (!api_sess->is_cert_extendable) {
ZTX_LOG(DEBUG, "identity certificate is not renewable");
goto done;
}

struct tm exp;
if (api_sess->cert_extend_requested || api_sess->key_roll_requested) {
ZTX_LOG(INFO, "controller requested certificate renewal (%s key roll)",
api_sess->key_roll_requested ? "with" : "without");
} else {
goto extend;
}

if (api_sess->is_cert_improper) {
ZTX_LOG(INFO, "controller reported certificate chain as incomplete");
goto extend;
}

// check if identity cert is expiring or expired
if (ztx->opts.cert_extension_window > 0) {
struct tm exp;
ztx->id_creds.cert->get_expiration(ztx->id_creds.cert, &exp);
time_t now = time(0);
time_t exptime = mktime(&exp);
Expand All @@ -2200,6 +2209,8 @@ static void api_session_cb(ziti_api_session *api_sess, const ziti_error *err, vo
1900 + exp.tm_year, exp.tm_mon + 1, exp.tm_mday, exp.tm_hour, exp.tm_min);
}

extend:

if ((ztx->opts.events & ZitiConfigEvent) == 0) {
ZTX_LOG(WARN, "identity certificate needs to be renewed "
"but application is not handling ZitiConfigEvent");
Expand Down
Loading