KeyGenerator.php in Simple OAuth (OAuth2) & OpenID Connect 5.x
File
src/Service/KeyGenerator.php
View source
<?php
namespace Drupal\simple_oauth\Service;
class KeyGenerator {
const CERT_CONFIG = [
"digest_alg" => "sha512",
"private_key_bits" => 4096,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
];
public static function generateKeys() {
$resource = openssl_pkey_new(KeyGenerator::CERT_CONFIG);
openssl_pkey_export($resource, $pkey);
$pubkey = openssl_pkey_get_details($resource);
return [
'private' => $pkey,
'public' => $pubkey['key'],
];
}
}