mailin icon indicating copy to clipboard operation
mailin copied to clipboard

ssl handshake failure

Open arashthk opened this issue 7 years ago • 9 comments

When receiving email from Yahoo I get this error message:

error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/s3_pkt.c:1493:SSL alert number 46
140050183874432:error:140940E5:SSL routines:ssl3_read_bytes:ssl handshake failure:../deps/openssl/openssl/ssl/s3_pkt.c:1216:

    at Error (native)
events.js:165
      throw err;
      ^

Error: Uncaught, unspecified "error" event. (undefined)
    at Mailin.emit (events.js:163:17)
    at SMTPServer.<anonymous> (/home/arash/.npm-global/lib/node_modules/mailin/lib/mailin.js:519:15)
    at emitOne (events.js:96:13)
    at SMTPServer.emit (events.js:188:7)
    at SMTPServer._onError (/home/arash/.npm-global/lib/node_modules/mailin/node_modules/smtp-server/lib/smtp-server.js:237:10)
    at emitOne (events.js:96:13)
    at SMTPConnection.emit (events.js:188:7)
    at SMTPConnection._onError (/home/arash/.npm-global/lib/node_modules/mailin/node_modules/smtp-server/lib/smtp-connection.js:274:10)
    at emitOne (events.js:101:20)
    at TLSSocket.emit (events.js:188:7)
    at emitErrorNT (net.js:1277:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
warn: It is likely that an error caused Mailin to crash.
warn: Please report this to https://github.com/Flolagale/mailin/issues

Ubuntu 14.04 OpenSSL 1.0.2k 26 Jan 2017 mailin version: 3.0.4 certificates are updated (apt-get install ca-certificates)

arashthk avatar May 29 '17 13:05 arashthk

I am having this issue as well. We have a server setup to receive files from vendors and 1 vendor in South Africa can never send files because this error pops up and crashes the server every time. I hope that there is a fix for this soon.

justin-haworth avatar Oct 26 '17 17:10 justin-haworth

Same issue here, any help please? the message appeared after upgrade to node 8.8.1

Kostanos avatar Oct 31 '17 17:10 Kostanos

Fixed the issue by adding valid (could be self signed) certificate to mailin config:

const options = {
    port: 25,
    disableWebhook: true,
    logFile: 'mailin.log,
    smtpOptions: {
        disableDNSValidation: true,
        disableDnsValidation: true,
        disableDkim: true,
        disableSpf: true,
        rejectUnauthorized: false,
        key: 'privkey.pem',
        cert: 'fullchain.pem',
    }
}
mailin.start(options);

My certificates are signed with LetsEncrypt. not sure if self signed would work, but should.

Kostanos avatar Nov 03 '17 01:11 Kostanos

I tried this using a .crt and .key files and had no luck. I do not know enough about the certs to fix whatever is broken in using them. The same files work just fine for the https for the app.

justin-haworth avatar Nov 06 '17 20:11 justin-haworth

okay just for anyone that might have tried @Kostanos solution to no avail, I do not know if he is using an older version of mailin, but I finally got his solution to work by removing the smtpOptions. in other words:

const options = { port: 25, disableWebhook: true, logFile: 'mailin.log, disableDNSValidation: true, disableDnsValidation: true, disableDkim: true, disableSpf: true, rejectUnauthorized: false, key: 'privkey.pem', cert: 'fullchain.pem' }

hope this helps someone.

justin-haworth avatar Nov 21 '17 15:11 justin-haworth

I'm using the latest version of mailin available - 3.0.4:

$ cat package-lock.json | grep mailin
    "mailin": {
      "resolved": "https://registry.npmjs.org/mailin/-/mailin-3.0.4.tgz",

I also found some code snippets using smtpOptions: https://github.com/Flolagale/mailin#embedded-inside-a-node-application

Kostanos avatar Nov 21 '17 16:11 Kostanos

I figured you were since your orig reply was so recent. I am also using the same version. For whatever reason, I had to change the options object. Figured it might help somebody else. Thanks for your reply.

justin-haworth avatar Nov 21 '17 16:11 justin-haworth

I feel like @Kostanos's config is right, since the option is originating from here, though I'm still having a bit of trouble getting my ssl emails routed right

AdeelK93 avatar Dec 14 '17 01:12 AdeelK93

I have no doubt or argument that his config is correct. I just wanted to point out that, for whatever reason, I could get not my app to start with a config similar to that. I had to adjust the smtp options. Just wanted to share it in case anyone else was getting the same initial results I was. I have no idea what I was doing differently outside of this config. Cheers.

justin-haworth avatar Dec 15 '17 01:12 justin-haworth