1

I have my MongoDB instance set up to use Authentication. I have my Mongo Connect BI setup to use the same authentication, but when I pass these authentication details through Cube.js I get the following error.

Error: ssl is required when using cleartext authentication at Packet.asError (/Users/Anton/Documents/Development/node/react-dashboard/node_modules/mysql2/lib/packets/packet.js:708:17) at ClientHandshake.execute (/Users/Anton/Documents/Development/node/react-dashboard/node_modules/mysql2/lib/commands/command.js:28:26) at Connection.handlePacket (/Users/Anton/Documents/Development/node/react-dashboard/node_modules/mysql2/lib/connection.js:408:32) at PacketParser.Connection.packetParser.p [as onPacket] (/Users/Anton/Documents/Development/node/react-dashboard/node_modules/mysql2/lib/connection.js:70:12) at PacketParser.executeStart (/Users/Anton/Documents/Development/node/react-dashboard/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/Users/Anton/Documents/Development/node/react-dashboard/node_modules/mysql2/lib/connection.js:77:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11)

My mongosqld command is as follows

mongosqld --mongo-uri "mongodb://XX.mlab.com:XX" -u DBUN -p DBPW --mongo-authenticationSource DBNAME --sampleNamespaces DBNAME.*

My Cube.js .ENV configuration is as follows

CUBEJS_DB_HOST=localhost CUBEJS_DB_NAME=DBNAME CUBEJS_DB_PORT=3307 CUBEJS_DB_TYPE=mongobi CUBEJS_DB_USER=DBUN CUBEJS_DB_PASS=DBPW

Any help would be greatly appreciated.

Thanks

Anton

AntonZ
  • 83
  • 2
  • 7

1 Answers1

2

Currently only cleartext authentication plugin is supported by Cube.js Mongo BI Driver. It requires SSL to be set up from both mongosqld and Cube.js side in order to encrypt passed credentials.

Self-signed certificate can be used to provide this encryption. It can be generated with following command:

$ openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem

Concat it together to create sslPEMKeyFile:

$ cat key.pem certificate.pem > mongo.pem

Start mongosqld with enabled SSL:

$ ./mongosqld --auth --sslMode requireSSL --sslPEMKeyFile mongo.pem

Add following environment variables to your Cube.js .env:

CUBEJS_DB_SSL=true
CUBEJS_DB_SSL_REJECT_UNAUTHORIZED=false

Non cleartext auth plugins support status: https://github.com/cube-js/cube.js/issues/222

Pavel Tiunov
  • 1,163
  • 6
  • 8
  • would say this helped me +1 this is working for me when i got the error while trying to connect to mongo bi from mysql workbench – Dravigon Oct 21 '22 at 07:10