@@ -65,10 +65,12 @@ public static function decode($jwt, $key = null, $verify = true)
65
65
if (empty ($ header ->alg )) {
66
66
throw new DomainException ('Empty algorithm ' );
67
67
}
68
- if (is_array ($ key ) && !isset ($ header ->kid )) {
69
- throw new DomainException ('"kid" empty, unable to lookup correct key ' );
70
- } elseif (is_array ($ key ) && isset ($ header ->kid )) {
71
- $ key = $ key [$ header ->kid ];
68
+ if (is_array ($ key )) {
69
+ if (isset ($ header ->kid )) {
70
+ $ key = $ key [$ header ->kid ];
71
+ } else {
72
+ throw new DomainException ('"kid" empty, unable to lookup correct key ' );
73
+ }
72
74
}
73
75
if (!JWT ::verify ("$ headb64. $ bodyb64 " , $ sig , $ key , $ header ->alg )) {
74
76
throw new UnexpectedValueException ('Signature verification failed ' );
@@ -116,7 +118,7 @@ public static function encode($payload, $key, $algo = 'HS256', $keyId = null)
116
118
* @param string $msg The message to sign
117
119
* @param string|resource $key The secret key
118
120
* @param string $method The signing algorithm. Supported
119
- * algorithms are 'HS256', 'HS384' and 'HS512 '
121
+ * algorithms are 'HS256', 'HS384', 'HS512' and 'RS256 '
120
122
*
121
123
* @return string An encrypted message
122
124
* @throws DomainException Unsupported algorithm was specified
0 commit comments