class KeyGenerator in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 8.3 src/Service/KeyGenerator.php \Drupal\simple_oauth\Service\KeyGenerator
- 5.x src/Service/KeyGenerator.php \Drupal\simple_oauth\Service\KeyGenerator
@internal
Hierarchy
- class \Drupal\simple_oauth\Service\KeyGenerator
Expanded class hierarchy of KeyGenerator
File
- src/
Service/ KeyGenerator.php, line 8
Namespace
Drupal\simple_oauth\ServiceView source
class KeyGenerator {
const CERT_CONFIG = [
"digest_alg" => "sha512",
"private_key_bits" => 4096,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
];
/**
* Generate a private and public key.
*
* @return array with the generated public and private key
*/
public static function generateKeys() {
// Generate Resource.
$resource = openssl_pkey_new(KeyGenerator::CERT_CONFIG);
// Get Private Key.
openssl_pkey_export($resource, $pkey);
// Get Public Key.
$pubkey = openssl_pkey_get_details($resource);
return [
'private' => $pkey,
'public' => $pubkey['key'],
];
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
KeyGenerator:: |
constant | |||
KeyGenerator:: |
public static | function | Generate a private and public key. |