Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-703

Timeout - trying to connect remotely (with auth and ssl)

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: MongoDB 3.2
    • Labels:
    • Environment:
      centos 7

      Description

      I have two websites (both mine) https://site1.com and https://site2.com

      I created a user for site1.com "benz" password "x". he has readWrite on "db" database.

      next on site2.com I put this node.js code and run it via the terminal:

      require('mongodb').MongoClient.connect(
      'mongodb://benz:xxxx@site1.com:27017/db?ssl=true&authMechanism=SCRAM-SHA-1&authSource=db'
      , {server:{
      sslValidate:true
      , checkServerIdentity:true
      , sslCA:[require('fs').readFileSync('/etc/letsencrypt/lets-encrypt-x3-cross-signed.pem')]
      , sslKey:require('fs').readFileSync('/etc/letsencrypt/live/site2.com/privkey.pem')
      , sslCert:require('fs').readFileSync('/etc/letsencrypt/live/site2.com/fullchain.pem')
      }}
      , function(e,db)

      { console.log(e,db); db.close(); }

      );

      I get

      { [MongoError: socket hang up] name: 'MongoError', message: 'socket hang up' }

      null

      /var/sentora/hostdata/zadmin/node_modules/mongodb/lib/server.js:235
      process.nextTick(function()

      { throw err; }

      )

      I turn both firewalls off and I get the same error!

      If I deliberately change my sslCert from `fullchain.pem` to `chain.pem` (another file that does exist) then I get a separate error

      Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
      at Error (native)
      at Object.createSecureContext (_tls_common.js:87:19)
      at Object.exports.connect (_tls_wrap.js:971:21)
      at Connection.connect (/var/sentora/hostdata/zadmin/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:348:27)
      at Immediate._onImmediate (/var/sentora/hostdata/zadmin/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:187:20)
      at processImmediate [as _immediateCallback] (timers.js:383:17)

      Which seems to show that the certs are fine but the auth is not fine

      I have run out of ideas

        Attachments

          Activity

            People

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            benzmuircroft@gmail.com Benz Muircroft
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: