beyondcode / herd-community

91 stars 1 forks source link

[Bug]: Mail service crashes when error happens (eg. TLS connection instead of None) #946

Closed barryvdh closed 1 month ago

barryvdh commented 2 months ago

Platform

macOS

Operating system version

MacOS Sonoma 14.5

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.9.1

PHP Version

No response

Bug description

When TLS is accidentally used, the Mail server crashes and does not start again. Requires Stop all + Start all to come back.

Expected error but should recoved and continue to accept messages gracefully when the configuration is corrected.

Steps to reproduce

Send a message with TLS enabled.

Relevant log output

Sending mail to Herd
node:events:515
      throw er; // Unhandled 'error' event
      ^

Error: 004CB6F401000000:error:0A000418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1584:SSL alert number 48

Emitted 'error' event on SMTPServer instance at:
    at SMTPServer._onError (/snapshot/herd-mailserver/node_modules/smtp-server/lib/smtp-server.js)
    at SMTPConnection.<anonymous> (/snapshot/herd-mailserver/node_modules/smtp-server/lib/smtp-server.js)
    at SMTPConnection.emit (node:events:537:28)
    at SMTPConnection._onError (/snapshot/herd-mailserver/node_modules/smtp-server/lib/smtp-connection.js)
    at TLSSocket.<anonymous> (/snapshot/herd-mailserver/node_modules/smtp-server/lib/smtp-connection.js)
    at Object.onceWrapper (node:events:652:26)
    at TLSSocket.emit (node:events:537:28)
    at TLSSocket._tlsError (node:_tls_wrap:907:8)
    at TLSSocket.emit (node:events:549:35)
    at emitErrorNT (node:internal/streams/destroy:151:8) {
  library: 'SSL routines',
  reason: 'tlsv1 alert unknown ca',
  code: 'ERR_SSL_TLSV1_ALERT_UNKNOWN_CA',
  remote: '127.0.0.1'
}

Node.js v18.5.0
mpociot commented 1 month ago

@barryvdh can you tell me how you reproduce this issue?