relay: add option to accept self-signed certs

This commit is contained in:
Girish Ramakrishnan
2019-04-23 15:19:33 -07:00
parent 7f9b078430
commit 91877f7b2d
3 changed files with 4 additions and 0 deletions

View File

@@ -1584,4 +1584,5 @@
* Preserve update backups for 3 weeks
* Make send test mail functionality work with secondary domain
* Add support for an external email relay that does not require authentication
* Add option to accept self-signed certs when using external mail relay

View File

@@ -180,6 +180,8 @@ function checkSmtpRelay(relay, callback) {
};
}
if (relay.acceptSelfSignedCerts) options.tls = { rejectUnauthorized: false };
var transporter = nodemailer.createTransport(smtpTransport(options));
transporter.verify(function(error) {

View File

@@ -170,6 +170,7 @@ function setMailRelay(req, res, next) {
if ('port' in req.body && typeof req.body.port !== 'number') return next(new HttpError(400, 'port must be a string'));
if ('username' in req.body && typeof req.body.username !== 'string') return next(new HttpError(400, 'username must be a string'));
if ('password' in req.body && typeof req.body.password !== 'string') return next(new HttpError(400, 'password must be a string'));
if ('acceptSelfSignedCerts' in req.body && typeof req.body.acceptSelfSignedCerts !== 'boolean') return next(new HttpError(400, 'acceptSelfSignedCerts must be a boolean'));
mail.setMailRelay(req.params.domain, req.body, function (error) {
if (error && error.reason === MailError.NOT_FOUND) return next(new HttpError(404, error.message));