Skip to content

Commit bad1b04

Browse files
authored
fix: check kid before using as array index
1 parent ddfaddc commit bad1b04

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/JWT.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,15 @@ private static function getKey(
425425
return $keyOrKeyArray;
426426
}
427427

428+
if (empty($kid)) {
429+
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
430+
}
431+
428432
if ($keyOrKeyArray instanceof CachedKeySet) {
429433
// Skip "isset" check, as this will automatically refresh if not set
430434
return $keyOrKeyArray[$kid];
431435
}
432436

433-
if (empty($kid)) {
434-
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
435-
}
436437
if (!isset($keyOrKeyArray[$kid])) {
437438
throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key');
438439
}

0 commit comments

Comments
 (0)