📧 fix: Correct Handling of Self-Signed Certificates in sendEmail (#2148)

- note: To put it in a different way, if you put rejectUnauthorized: true, it means that self-signed certificates should not be allowed. This means, that EMAIL_ALLOW_SELFSIGNED is set to false
This commit is contained in:
Danny Avila 2024-03-20 11:48:54 -04:00 committed by GitHub
parent f7761df52c
commit e4ac58012f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ const fs = require('fs');
const path = require('path');
const nodemailer = require('nodemailer');
const handlebars = require('handlebars');
const { isEnabled } = require('~/server/utils');
const logger = require('~/config/winston');
const sendEmail = async (email, subject, payload, template) => {
@ -13,7 +14,7 @@ const sendEmail = async (email, subject, payload, template) => {
requireTls: process.env.EMAIL_ENCRYPTION === 'starttls',
tls: {
// Whether to accept unsigned certificates
rejectUnauthorized: process.env.EMAIL_ALLOW_SELFSIGNED === 'true',
rejectUnauthorized: !isEnabled(process.env.EMAIL_ALLOW_SELFSIGNED),
},
auth: {
user: process.env.EMAIL_USERNAME,