MDL-77840 lti: Avoid passing nulls to base64_encode
This commit is contained in:
@@ -262,6 +262,11 @@ class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
|
||||
// Sign using the key
|
||||
$ok = openssl_sign($base_string, $signature, $privatekeyid);
|
||||
|
||||
// Avoid passing null values to base64_encode.
|
||||
if (!$ok) {
|
||||
throw new OAuthException("OpenSSL unable to sign data");
|
||||
}
|
||||
|
||||
// TODO: Remove this block once PHP 8.0 becomes required.
|
||||
if (PHP_MAJOR_VERSION < 8) {
|
||||
// Release the key resource
|
||||
|
||||
@@ -73,6 +73,11 @@ class jwks_helper {
|
||||
$res = openssl_pkey_get_private($privatekey['key']);
|
||||
$details = openssl_pkey_get_details($res);
|
||||
|
||||
// Avoid passing null values to base64_encode.
|
||||
if (!isset($details['rsa']['e']) || !isset($details['rsa']['n'])) {
|
||||
throw new \moodle_exception('Error: essential openssl keys not set');
|
||||
}
|
||||
|
||||
$jwk = array();
|
||||
$jwk['kty'] = 'RSA';
|
||||
$jwk['alg'] = 'RS256';
|
||||
|
||||
Reference in New Issue
Block a user