protected function LockrRenewForm::createCSR in Lockr 4.x
Creates a new RSA private key and CSR pair.
1 call to LockrRenewForm::createCSR()
- LockrRenewForm::submitForm in src/
Form/ LockrRenewForm.php - Form submission handler.
File
- src/
Form/ LockrRenewForm.php, line 274
Class
- LockrRenewForm
- Form handler for Lockr renew cert.
Namespace
Drupal\lockr\FormCode
protected function createCSR() {
$key = openssl_pkey_new([
'private_key_bits' => 2048,
]);
if ($key === FALSE) {
return NULL;
}
if (!openssl_pkey_export($key, $key_text)) {
return NULL;
}
$dn = [
'countryName' => 'US',
'stateOrProvinceName' => 'Washington',
'localityName' => 'Tacoma',
'organizationName' => 'Lockr',
];
$csr = openssl_csr_new($dn, $key);
if ($csr === FALSE) {
return NULL;
}
if (!openssl_csr_export($csr, $csr_text)) {
return NULL;
}
return [
'key_text' => $key_text,
'csr_text' => $csr_text,
];
}