After Deployment : Node IMAP MailListener with Office365 & SSLv3 Error: 140059098205512:error:1408F10B:SSL

After Deployment : Node IMAP MailListener with Office365 & SSLv3 Error: 140059098205512:error:1408F10B:SSL

我正在使用 Node 13。部署代码后我无法连接到我的 IMAP Outlook 服务器。在较新的版本中,出于安全原因禁用了 ssl3。就我的目的而言,这并不重要。我只是想让它在部署后工作。我使用 docker 图像和 linux.

进行部署

MailListener 配置

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0

//Config für MailListner
// Dokumentation und Code beispiel:
//https://www.npmjs.com/package/mail-listener5
var mailListener = new MailListener({
    username: process.env.email,
    password: process.env.password,
    host: process.env.host,
    port: process.env.port,
    //secureConnection
    secureConnection: true,
    connTimeout: 30000, // Default by node-imap
    authTimeout: 15000, // Default by node-imap,
    debug: console.log, // Or your custom function with only one incoming argument. Default: null
    //tls:true,
/*     tls:{
        ciphers:'SSLv3'
    }, */
    tls:{
        ciphers:'TLSv1'
    },
    tlsOptions: {
        //secureProtocol: 'SSLv3_method' , 
        secureProtocol: 'TLSv1_method' ,
        rejectUnauthorized: false
    }, 
    mailbox: "INBOX", // mailbox to monitor
    searchFilter: ["UNSEEN"], // the search filter being used after an IDLE notification has been retrieved
    markSeen: true, // all fetched email willbe marked as seen and not fetched next time
    fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
    autopurge: true // mail.attachments[0]e mit delete Flag werden gelöscht
});

.ENV

host=outlook.office365.com
port=993

此代码仅在本地运行。部署后我得到

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

    at Socket.ondata (internal/js_stream_socket.js:72:22)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:273:9)
    at Socket.Readable.push (_stream_readable.js:214:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
Emitted 'error' event on MailListener instance at:
    at MailListener.imapError (/usr/src/app/node_modules/mail-listener5/index.js:88:10)
    at Connection.emit (events.js:315:20)
    at TLSSocket._onError (/usr/src/app/node_modules/imap/lib/Connection.js:151:10)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:84:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  library: 'SSL routines',
  function: 'ssl3_get_record',
  reason: 'wrong version number',
  code: 'ERR_SSL_WRONG_VERSION_NUMBER',
  source: 'socket'
}

当运行 SSLv3 配置时

_tls_common.js:74
  this.context.init(secureProtocol,
               ^

TypeError: SSLv3 methods disabled
    at new SecureContext (_tls_common.js:74:16)
    at Object.createSecureContext (_tls_common.js:101:13)
    at Object.connect (_tls_wrap.js:1583:48)
    at Connection.connect (C:\Users\user\Desktop\Dev\webservice_email_upload\node_modules\imap\lib\Connection.js:128:22)
    at MailListener.start (C:\Users\user\Desktop\Dev\webservice_email_upload\node_modules\mail-listener5\index.js:55:15)
    at Object.<anonymous> (C:\Users\user\Desktop\Dev\webservice_email_upload\app.js:107:14)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'ERR_TLS_INVALID_PROTOCOL_METHOD'

提前感谢您的帮助!

已解决

正如我之前提到的,我使用的是 Node 13。我没有提到的是我使用的 Linux 发行版。

切换后

Node:13-alpine 到 node:lts-buster-slim(Ubuntu 瘦身版)成功了!