public function JwtTranscoder::setPublicKey in JSON Web Token Authentication (JWT) 8.0
Same name and namespace in other branches
- 8 src/Transcoder/JwtTranscoder.php \Drupal\jwt\Transcoder\JwtTranscoder::setPublicKey()
Sets the public key used to verify signatures for an asymmetric algorithm.
This key is only used when an asymmetric algorithm is selected. Currently supported asymmetric algorithms are:
- RS256
Parameters
string $public_key: A PEM encoded public key.
Return value
mixed Function does some validation of the key. Returns TRUE on success.
Overrides JwtTranscoderInterface::setPublicKey
File
- src/
Transcoder/ JwtTranscoder.php, line 157
Class
- JwtTranscoder
- Class JwtTranscoder.
Namespace
Drupal\jwt\TranscoderCode
public function setPublicKey($public_key) {
$key_context = openssl_pkey_get_public($public_key);
$key_details = openssl_pkey_get_details($key_context);
if ($key_details === FALSE || $key_details['type'] != OPENSSL_KEYTYPE_RSA) {
return FALSE;
}
$this->publicKey = $public_key;
return TRUE;
}