Search code examples
node.jslinuxemailoutlookimap

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


Im using Node 13. I cant connect to my IMAP Outlook Server after deploying the code. In newer versions ssl3 is disabled for security reasons. For my purpose, it dosent matter. I just wanna get it working after deployment. I deploy with docker images and linux.

MailListener Config

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

This Code runs only Local. After deploying i get

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'
}

When Running with SSLv3 Config

_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'

Thanks for youre help in advance !


Solution

  • Solved

    As I mentioned before, i used Node 13. What i didnt mentioned was the Linux Distribution that i was using.

    After switching from

    Node:13-alpine to node:lts-buster-slim (Ubuntu Slim Version) it worked!