public static function KeyGenerator::generateKeys 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::generateKeys()
- 5.x src/Service/KeyGenerator.php \Drupal\simple_oauth\Service\KeyGenerator::generateKeys()
Generate a private and public key.
Return value
array with the generated public and private key
1 call to KeyGenerator::generateKeys()
- KeyGeneratorService::generateKeys in src/
Service/ KeyGeneratorService.php - Generate both public key and private key on the given paths.
File
- src/
Service/ KeyGenerator.php, line 21
Class
- KeyGenerator
- @internal
Namespace
Drupal\simple_oauth\ServiceCode
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'],
];
}