Search code examples
node.jsmongodbmongodb-csfle

Unable understand how to install libmongocrypt


I am trying to setup a mongo connection in NODE.js with autoEncrypt option and it of course tries to connect with the driver at port 27020. I don't have libmongocrypt service running so the connection generates the following error.

ECONNREFUSED 127.0.0.1:27020

I am trying to implement manual encryption with bypassAutoEncryption flag.

I am aware we have to use this library but it appears to be a C library and I am still clueless how I can setup libmongocrypt on my local environment.

OS: Windows 10 MONGO VERSION: 5.0

Any help would be appreciated! Thank you


Solution

  • I'm not familiar with Node itself, but these are common details about this workflow (writing it as answer since it's quite big):

    1. libmongocrypt is a C library that is used by the driver, usually it's embedded in the driver (unless Node doesn't support it for some reason).
    2. ECONNREFUSED 127.0.0.1:27020 this error says that a process required for encryption called mongocryptd is not launched, it's not the same as libmongocrypt library (it's completely different things), you can launch this process by:
      • Just manual launch. This file is placed in SERVER_PATH\bin\mongocryptd.exe. Use it only as quick check.
      • Filling autoEncryption.extraOptions.mongocryptdSpawnPath with the path to mongocryptd.exe, you can find some details here

    it's worth mention that auto encryption (along with mongocryptd) is available only in enterprise server.