@@ -65,10 +65,12 @@ public static function decode($jwt, $key = null, $verify = true)
6565 if (empty ($ header ->alg )) {
6666 throw new DomainException ('Empty algorithm ' );
6767 }
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+ }
7274 }
7375 if (!JWT ::verify ("$ headb64. $ bodyb64 " , $ sig , $ key , $ header ->alg )) {
7476 throw new UnexpectedValueException ('Signature verification failed ' );
@@ -116,7 +118,7 @@ public static function encode($payload, $key, $algo = 'HS256', $keyId = null)
116118 * @param string $msg The message to sign
117119 * @param string|resource $key The secret key
118120 * @param string $method The signing algorithm. Supported
119- * algorithms are 'HS256', 'HS384' and 'HS512 '
121+ * algorithms are 'HS256', 'HS384', 'HS512' and 'RS256 '
120122 *
121123 * @return string An encrypted message
122124 * @throws DomainException Unsupported algorithm was specified
0 commit comments