Skip to content

Commit 81092f0

Browse files
committed
enrollment: properly find jwt signing input
1 parent 8edb466 commit 81092f0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

library/ziti_enroll.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,16 @@ int verify_controller_jwt(const struct tlsuv_certificate_s *cert, void *ctx) {
7676
return -1;
7777
}
7878

79+
// find second dot to get the signing input portion of the JWT
80+
// should never fail here since we already parsed the JWT
81+
const char *dot = strchr(er->opts.token, '.');
82+
if (dot == NULL || (dot = strchr(dot + 1, '.')) == NULL) {
83+
ZITI_LOG(ERROR, "invalid JWT format");
84+
return -1;
85+
}
86+
7987
int rc = cert->verify(cert, md, er->opts.token,
80-
strlen(er->opts.token),
88+
dot - er->opts.token,
8189
er->sig, er->sig_len);
8290
if (rc != 0) {
8391
ZITI_LOG(ERROR, "failed to verify JWT signature");

0 commit comments

Comments
 (0)