Reputation:
So I'm doing this app in Node.js with express and I have this error Error: self signed certificate in certificate chain
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'ESOCKET', command: 'CONN' }
POST /contact/send - - ms - -
I have change the mail service and also disavaible my antivirus, I cant find the sokution online, and a little bit of help is good for everybody
Thank youu
Upvotes: 19
Views: 41965
Reputation: 159
You can fix it adding
tls: {
rejectUnauthorized: false
}
like @ty2k suggest to the transporter object. Or maybe its your antivirus, I cancel my Avast shell and now its working.
Upvotes: 2
Reputation: 1
email: {
smtp: {
host: SMTP_HOST,
port: 465,
secure: true,
requireTLS: false,
auth: {
user: SMTP_USERNAME,
pass: SMTP_PASSWORD,
},
},
from: EMAIL_FROM,
}
Upvotes: 0
Reputation: 853
There is a good discussion about using Nodemailer with self-signed certificates in this GitHub issue. Specifically, this post can help get rid of the error message:
If you know that the host does not have a valid certificate you can allow it in the transport settings with
tls.rejectUnauthorized
option:
var transporter = nodemailer.createTransport(smtpTransport({ host: "outmail.abc.co.th", // hostname secure: false, // use SSL port: 25, // port for secure SMTP auth: { user: "[email protected]", pass: "passwordmail" }, tls: { rejectUnauthorized: false } }));
However, if you believe the mail services you are trying to use have valid certificates, you might have a local issue with your machine or network.
Upvotes: 63