Set the dkim selector when generating keys
The box code owns the dkim dir and selector can change per domain
This commit is contained in:
+4
-1
@@ -476,8 +476,9 @@ function ensureDkimKey(callback) {
|
|||||||
var dkimPath = path.join(paths.MAIL_DATA_DIR, 'dkim/' + config.fqdn());
|
var dkimPath = path.join(paths.MAIL_DATA_DIR, 'dkim/' + config.fqdn());
|
||||||
var dkimPrivateKeyFile = path.join(dkimPath, 'private');
|
var dkimPrivateKeyFile = path.join(dkimPath, 'private');
|
||||||
var dkimPublicKeyFile = path.join(dkimPath, 'public');
|
var dkimPublicKeyFile = path.join(dkimPath, 'public');
|
||||||
|
var dkimSelectorFile = path.join(dkimPath, 'selector');
|
||||||
|
|
||||||
if (!fs.existsSync(dkimPrivateKeyFile) || !fs.existsSync(dkimPublicKeyFile)) {
|
if (!fs.existsSync(dkimPrivateKeyFile) || !fs.existsSync(dkimPublicKeyFile) || !fs.existsSync(dkimSelectorFile)) {
|
||||||
debug('Generating new DKIM keys');
|
debug('Generating new DKIM keys');
|
||||||
|
|
||||||
if (!safe.fs.mkdirSync(dkimPath) && safe.error.code !== 'EEXIST') {
|
if (!safe.fs.mkdirSync(dkimPath) && safe.error.code !== 'EEXIST') {
|
||||||
@@ -487,6 +488,8 @@ function ensureDkimKey(callback) {
|
|||||||
|
|
||||||
child_process.execSync('openssl genrsa -out ' + dkimPrivateKeyFile + ' 1024');
|
child_process.execSync('openssl genrsa -out ' + dkimPrivateKeyFile + ' 1024');
|
||||||
child_process.execSync('openssl rsa -in ' + dkimPrivateKeyFile + ' -out ' + dkimPublicKeyFile + ' -pubout -outform PEM');
|
child_process.execSync('openssl rsa -in ' + dkimPrivateKeyFile + ' -out ' + dkimPublicKeyFile + ' -pubout -outform PEM');
|
||||||
|
|
||||||
|
safe.fs.writeFileSync(dkimSelectorFile, config.dkimSelector(), 'utf8');
|
||||||
} else {
|
} else {
|
||||||
debug('DKIM keys already present');
|
debug('DKIM keys already present');
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -260,7 +260,7 @@ function createMailConfig(callback) {
|
|||||||
var mailFromValidation = result[settings.MAIL_FROM_VALIDATION_KEY];
|
var mailFromValidation = result[settings.MAIL_FROM_VALIDATION_KEY];
|
||||||
|
|
||||||
if (!safe.fs.writeFileSync(paths.ADDON_CONFIG_DIR + '/mail/mail.ini',
|
if (!safe.fs.writeFileSync(paths.ADDON_CONFIG_DIR + '/mail/mail.ini',
|
||||||
`mail_domain=${fqdn}\nmail_server_name=${mailFqdn}\nalerts_from=${alertsFrom}\nalerts_to=${alertsTo}\ncatch_all=${catchAll}\nmail_from_validation=${mailFromValidation}\ndkim_selector=${config.dkimSelector()}\n`, 'utf8')) {
|
`mail_domain=${fqdn}\nmail_server_name=${mailFqdn}\nalerts_from=${alertsFrom}\nalerts_to=${alertsTo}\ncatch_all=${catchAll}\nmail_from_validation=${mailFromValidation}\n`, 'utf8')) {
|
||||||
return callback(new Error('Could not create mail var file:' + safe.error.message));
|
return callback(new Error('Could not create mail var file:' + safe.error.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user