forked from luciferous/jwt
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
The RS256 example in the readme file can run in my runtime:
- OpenSSL Library Version: OpenSSL 1.0.2k 26 Jan 2017
- PHP version: 7.1.9
- API Framework: ThinkPHP 5.0
$jwt = JWT::encode($token, $privateKey, 'RS256');
$decoded_before_expired = JWT::decode($jwt, $publicKey, array('RS256'));
But when I try to use RS512 publicKey/privateKey in the example without any changes in the code, it just run as perfect as with the RS256 keys of the example which means I still use the RS256
mode to encode and decode my jwt!
And when I try to use RS512
mode in the example code like this:
$jwt = JWT::encode($token, $privateKey, 'RS512');
$decoded_before_expired = JWT::decode($jwt, $publicKey, array('RS512'));
The php framework just told me:
DomainException in JWT.php line 201
OpenSSL unable to sign data
}
list($function, $algorithm) = static::$supported_algs[$alg];
switch($function) {
case 'hash_hmac':
return hash_hmac($algorithm, $msg, $key, true);
case 'openssl':
$signature = '';
$success = openssl_sign($msg, $signature, $key, $algorithm);
if (!$success) {
throw new DomainException("OpenSSL unable to sign data");
} else {
return $signature;
}
}
}
/**
* Verify a signature with the message, key and method. Not all methods
* are symmetric, so we must have a separate verify and sign method.
All fine in the RS256
mode, did I misunderstand something here?
Metadata
Metadata
Assignees
Labels
No labels