nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

SSL Wrong Version Number on HELO #170

Closed AlexIsOK closed 2 years ago

AlexIsOK commented 2 years ago

i get the following error when i receive a HELO message: (/path is filler):

events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: 281473174790160:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

Emitted 'error' event on SMTPServer instance at:
    at SMTPServer._onError (/path/node_modules/smtp-server/lib/smtp-server.js:332:14)
    at /path/node_modules/smtp-server/lib/smtp-server.js:72:41
    at TLSSocket.onError (/path/node_modules/smtp-server/lib/smtp-server.js:473:13)
    at Object.onceWrapper (events.js:520:26)
    at TLSSocket.emit (events.js:400:28)
    at TLSSocket._tlsError (_tls_wrap.js:897:8)
    at TLSSocket.emit (events.js:412:35)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  library: 'SSL routines',
  function: 'ssl3_get_record',
  reason: 'wrong version number',
  code: 'ERR_SSL_WRONG_VERSION_NUMBER'
}

with the following:

const smtp_server = new SMTPServer({
    secure: true,
    cert: fs.readFileSync("./ssl/cert.pem"),
    key: fs.readFileSync("./ssl/key.pem"),
    minVersion: "TLSv1.2",
    maxVersion: "TLSv1.3",
    size: 1048576,
    onData(stream: SMTPServerDataStream, session: SMTPServerSession, callback: (err?: (Error | null)) => void) {}
});

the cert and keys i'm using were generated using cloudflare on my domain.

non-secure connections work perfectly.

how do i fix this issue? using ubuntu 20.04.

andris9 commented 2 years ago

Set an error handler for the server instance as show here: https://nodemailer.com/extras/smtp-server/#handling-errors

most probably the client does not support newer tls versions

AlexIsOK commented 2 years ago

Set an error handler for the server instance as show here: https://nodemailer.com/extras/smtp-server/#handling-errors

most probably the client does not support newer tls versions

did that, still get the error after upgrading to openssl 3.0.0-7:

error handled: 281473048203280:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

adding error handling just prevents the program from crashing, i still am not receiving anything after the initial HELO as the socket closes.

almostkareem commented 2 years ago

Hey Alex, Did you solve the problem, stuck at the same thing here

xegulon commented 2 years ago

Also stuck there.

AlexIsOK commented 2 years ago

unfortunately i did not solve it, i just decided not to use ssl on my email server since i did not need it (it's for temp emails anyways)