[Web] Allow to overwrite DKIM keys while importing a new key
parent
53dd02bc63
commit
23f118a152
|
@ -150,6 +150,7 @@ function dkim($_action, $_data = null, $privkey = false) {
|
|||
return false;
|
||||
}
|
||||
$private_key_input = trim($_data['private_key_file']);
|
||||
$overwrite_existing = intval($_data['overwrite_existing']);
|
||||
$private_key_normalized = preg_replace('~\r\n?~', "\n", $private_key_input);
|
||||
$private_key = openssl_pkey_get_private($private_key_normalized);
|
||||
if ($ssl_error = openssl_error_string()) {
|
||||
|
@ -178,13 +179,15 @@ function dkim($_action, $_data = null, $privkey = false) {
|
|||
return false;
|
||||
}
|
||||
if ($redis->hGet('DKIM_PUB_KEYS', $domain)) {
|
||||
if ($overwrite_existing == 0) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
'log' => array(__FUNCTION__, $_action, $_data, $privkey),
|
||||
'msg' => array('dkim_domain_or_sel_invalid', $domain)
|
||||
'msg' => array('dkim_domain_or_sel_exists', $domain)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!ctype_alnum($dkim_selector)) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
|
@ -194,6 +197,7 @@ function dkim($_action, $_data = null, $privkey = false) {
|
|||
return false;
|
||||
}
|
||||
try {
|
||||
dkim('delete', $domain);
|
||||
$redis->hSet('DKIM_PUB_KEYS', $domain, $pem_public_key);
|
||||
$redis->hSet('DKIM_SELECTORS', $domain, $dkim_selector);
|
||||
$redis->hSet('DKIM_PRIV_KEYS', $dkim_selector . '.' . $domain, $private_key_normalized);
|
||||
|
|
Loading…
Reference in New Issue