Cubejs : Error: 19488:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332: - mongodb

I am trying to connect Cubejs to MongoDB through MongoDB BI Connect.
My mongosqld command is as follows
./mongosqld --config mongosqld.conf -u useradmin -p xxxx --auth --sslMode requireSSL --sslPEMKeyFile mongo.pem
I have created mongo.pem file by referring below link
Cube.js: Error: ssl is required when using cleartext authentication using MongoDB BI Connector
My Cube.js .ENV configuration is as follows
CUBEJS_DEV_MODE=true
CUBEJS_DB_TYPE=mongobi
CUBEJS_API_SECRET= xxxxxx
CUBEJS_EXTERNAL_DEFAULT=true
CUBEJS_SCHEDULED_REFRESH_DEFAULT=true
CUBEJS_WEB_SOCKETS=true
CUBEJS_DB_HOST=localhost
CUBEJS_DB_NAME=RDM
CUBEJS_DB_USER=useradmin
CUBEJS_DB_PASS=xxxx
CUBEJS_DB_SSL=true
CUBEJS_DB_SSL_REJECT_UNAUTHORIZED=false
After trying to connect Error shown in cubejs
Runtime Error
Cube.js was unable to connect to the specified database.
The database returned the following error:
>Database Error
Error: Error: 19488:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
And below error in mongosqld run on powershell
2021-10-12T17:15:06.045+0000 I NETWORK [conn1] connection accepted from 127.0.0.1:61457 #1 (1 connection now open)
2021-10-12T17:15:06.056+0000 E NETWORK [conn1] handshake error: ERROR 1043 (08S01): recv handshake response error: ERROR 1043 (08S01): ssl configuration error: UseCertificateChainFile: SSL errors: 906d06c:PEM routines:PEM_read_bio:no start line
140dc009:SSL routines:SSL_CTX_use_certificate_chain_file:PEM lib
2021-10-12T17:15:06.057+0000 I NETWORK [conn1] end connection 127.0.0.1:61457 (0 connections now open)
From the error I understand that the .pem file generated is not correct. Can someone please help me in this ?

Related

MacOS Catalina Wont connect to MONGODB Server on Google Compute Engine

I have a problems on my Macbook 15" Catalina to access Mongodb run in docker compute engine. If i use other laptop connection work well without error or with other os like ubuntu or windows that no problems. Cant connect just in my macbook 15" with os Catalina.
Error on mongo command :
▶mongo [PublicIP-VMInstance]:[PortMongo]/admin -u username -p password
MongoDB shell version v3.6.14
connecting to: mongodb://[PublicIP-VMInstance]:[PortMongo]/admin?gssapiServiceName=mongodb
2019-11-23T18:22:30.975+0700 I NETWORK [thread1] Socket recv() Connection reset by peer [PublicIP-VMInstance]:[PortMongo]
2019-11-23T18:22:30.975+0700 I NETWORK [thread1] SocketException: remote: (NONE):0 error: SocketException socket exception [RECV_ERROR] server [[PublicIP-VMInstance]:[PortMongo]]
2019-11-23T18:22:30.975+0700 E QUERY [thread1] Error: network error while attempting to run command 'isMaster' on host '[PublicIP-VMInstance]:[PortMongo]' :
connect#src/mongo/shell/mongo.js:263:13
#(connect):1:6
exception: connect failed
show error if i use --ssl flag :
▶mongo [PublicIP-VMInstance]:[PortMongo]/admin -u username -p password --ssl --verbose
MongoDB shell version v3.6.14
connecting to: mongodb://[PublicIP-VMInstance]:[PortMongo]/admin?gssapiServiceName=mongodb
2019-11-23T11:47:19.836+0700 D NETWORK [thread1] creating new connection to:[PublicIP-VMInstance]:[PortMongo]
2019-11-23T11:47:19.839+0700 I NETWORK [thread1] Socket recv() Connection reset by peer [PublicIP-VMInstance]:[PortMongo]
2019-11-23T11:47:19.839+0700 E QUERY [thread1] Error: socket exception [RECV_ERROR] for [PublicIP-VMInstance]:[PortMongo] :
connect#src/mongo/shell/mongo.js:263:13
#(connect):1:6
2019-11-23T11:47:19.839+0700 D - [thread1] User Assertion: 12513:connect failed src/mongo/shell/shell_utils.cpp 279
2019-11-23T11:47:19.839+0700 I QUERY [thread1] MozJS GC prologue heap stats - total: 3447601 limit: 0
2019-11-23T11:47:19.840+0700 I QUERY [thread1] MozJS GC epilogue heap stats - total: 1641 limit: 0
2019-11-23T11:47:19.840+0700 I QUERY [thread1] MozJS GC prologue heap stats - total: 3937 limit: 0
2019-11-23T11:47:19.841+0700 I QUERY [thread1] MozJS GC epilogue heap stats - total: 9 limit: 0
2019-11-23T11:47:19.841+0700 D - [main] User Assertion: 12513:connect failed src/mongo/scripting/mozjs/proxyscope.cpp 302
exception: connect failed
If use GUI Client like NoSQLBooster show error :
12:53:53.307 *** Starting MongoClient.connect ***
{"options":{"appname":"NoSQLBoosterV5.2.7_125336.468","autoReconnect":true,"keepAlive":60000,"poolSize":0,"promoteLongs":false,"promoteValues":false,"reconnectTries":172800,"socketTimeoutMS":0,"sslValidate":false,"useNewUrlParser":true},"uri":"mongodb://username:******#IPPublic-VMInstance:PORTMONGO?authSource=admin"}
12:53:53.311 *** Connect Error ***
{"errorLabels":["TransientTransactionError"],"message":"failed to connect to server [IPPublic-VMInstance:PORTMONGO] on first connect [MongoNetworkError: read ECONNRESET]","name":"MongoNetworkError","stack":"MongoNetworkError: failed to connect to server [IPPublic-VMInstance:PORTMONGO] on first connect [MongoNetworkError: read ECONNRESET]\n at Pool.<anonymous> (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/topologies/server.js:431:11)\n at Pool.emit (events.js:182:13)\n at connect (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/pool.js:557:14)\n at callback (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/connect.js:109:5)\n at runCommand (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/connect.js:129:7)\n at Connection.errorHandler (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/connect.js:321:5)\n at Object.onceWrapper (events.js:273:13)\n at Connection.emit (events.js:182:13)\n at Socket.<anonymous> (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/connection.js:321:10)\n at Object.onceWrapper (events.js:273:13)\n at Socket.emit (events.js:182:13)\n at emitErrorNT (internal/streams/destroy.js:82:8)\n at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)\n at process._tickCallback (internal/process/next_tick.js:63:19)"}
I have try with this tutorial :
openssl problems
https://community.exploratory.io/t/mongodb-ssl-connection-error-on-mac-os-x/832 [ still not working ]
use --ssl but in other laptop work well without this options
Apple has made TLS requirements stricter in Catalina. I have a similar case where the connection from Catalina fails using the mongo cli client. I couldn't find statements about changes in behavior of SSL specifically (which I am using). They may have changed something they didn't communicate.
About Catalina TLS changes: https://support.apple.com/en-us/HT210176
If I run a VM Ubuntu on Catalina, I'm able to connect from there. Also macs with Mojave can connect just fine using the same certificates, keys, and network.
Below is the error I'm seeing. It's slightly different to yours but also something that only happens on Catalina.
mongo --host myhost.com --ssl --sslCAFile ca.pem --sslPEMKeyFile client.pem -u myuser -p
W CONTROL [main] Option: ssl is deprecated. Please use tls instead.
W CONTROL [main] Option: sslPEMKeyFile is deprecated. Please use tlsCertificateKeyFile instead.
W CONTROL [main] Option: sslCAFile is deprecated. Please use tlsCAFile instead.
MongoDB shell version v4.2.1
Enter password:
connecting to: mongodb://myhost.com:27017/?compressors=disabled&gssapiServiceName=mongodb
E NETWORK [js] SSL peer certificate validation failed: Certificate trust failure: Host name mismatch; connection rejected
E QUERY [js] Error: couldn't connect to server myhost.com:27017, connection attempt failed: SSLHandshakeFailed:
SSL peer certificate validation failed: Certificate trust failure: Host name mismatch; connection rejected :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
F - [main] exception: connect failed
E - [main] exiting with code 1
I suggest you try generating new certificates that match Apple's new requirements if that's at all possible. Another thing you could try would be to run a Linux VM on your Mac and see if the connection works from there. If it does, I reckon it would narrow the issue down to the certificates themselves.
Update: Docker seems to be an alternative for the VM. Using a Docker container on a Mac with Catalina I can connect to mongo just fine.
Are you certain that PublicIP-VMInstance and PortMongo are resolving to IP addresses and a port by your mongo client? I'm running MacOS X 10.15.1 (Catalina) and Mongo client 4.2.1 and connections work perfectly for me using a connection string like this:
/opt/local/bin/mongo --ssl --sslAllowInvalidCertificates --host=mongo.mydomain.com:27017 -u mongoMatt -p dont*You*Wish

Connection error while installing mongodb on Fedora 28

I have been trying to install Mongodb but it keeps failing midway. When the download is complete, installation fails with a connection error:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-08-17T12:26:33.340+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-08-17T12:26:33.340+0200 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
What I've tried:
1. Changing the port:
mongo --port 4332
but it doesn't connect still:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:4332/
2018-08-17T12:32:55.743+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:4332, in(checking socket for error after poll), reason: Connection refused
2018-08-17T12:32:55.743+0200 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:4332, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
Reinstalling the DB shows up as complete but I still can't start it. Check out the screenshot
Checking for any config files in /etc/mongo* or /var/lib/: there is none.
Note: There's no mongod service available too.
the installation seem to have worked, but the mongod was not started.
MongoDB need two element :
the "mongo" shell utility, who is used to connect to the database direcly
the "mongod" service, who is the true database programs.
to start the mongod, simply use a cmd and use the "mongod" command. this command may fail if :
the port is already used (default is 27017)
the dbpath directory was not created (default is /data/db)
Fedora repository do not install both at the same time.
the shell is in the repository under the "mongodb" name
the server is under the name "mongodb-server"
so to install both, you need to do
dnf install mongodb mongodb-server
and you can then start the mongod service with
sudo service mongod start
more information

LetsEncrypt SSL Certificate Validation Failed with MongoDB

A little background...my certificate is a LetsEncrypt.org SSL certificate issued with Certbot. I'm running Nginx 1.12.2, and I'm able to properly access my website using https:// so I believe that portion is configured properly. My web server is running Ubuntu 16.04 and MongoDB 3.6.3.
I have tried many configurations and while I can connect to my MongoDB just fine using Compass (the official MongoDB GUI) without the SSL option, attempts to connect with SSL result in a Could not connect to MongoDB on the provided host and port error message. Running mongo -ssl --sslPEMKeyFile /etc/ssl/mongo.pem on my server results in the following error:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-06-12T16:51:10.756+0000 E NETWORK [thread1] SSL peer certificate validation failed: unable to get local issuer certificate
2018-06-12T16:51:10.757+0000 E QUERY [thread1] Error: socket exception [CONNECT_ERROR] for SSL peer certificate validation failed: unable to get local issuer certificate :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
My /var/log/mongodb/mongod.log shows the following which corresponds to the error above:
2018-06-12T16:51:10.755+0000 I NETWORK [listener] connection accepted from 127.0.0.1:47792 #8 (2 connections now open)
2018-06-12T16:51:10.757+0000 I NETWORK [conn8] end connection 127.0.0.1:47792 (1 connection now open)
My /etc/mongod.conf contains the following (I've commented out the CAFile parameter as I've read this is optional for now [source: https://stackoverflow.com/a/33926129/2969615 ]; note that I get mongo.pem: OK when running the openssl verify -CAfile /etc/ca.pem /etc/mongo.pem command, so I believe mongo.pem is properly set up):
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
ssl:
mode: allowSSL
PEMKeyFile: /etc/ssl/mongo.pem
# CAFile: /etc/ssl/ca.pem
I've created my mongo.pem file by referring to the following: https://serverfault.com/a/878457 ...I have tried the certificate in the instructions as well as both X3 intermediate certificates available at https://letsencrypt.org/certificates/ to no avail.
Any help would be greatly appreciated.
Very late to the party, but just in case it does help someone. I am running mongodb inside docker with the official image from mongo and compass from another docker image.
For the server I use:
docker run -it --name data.domain.com --network docker_network -v /path/to/ssl:/ssl:ro -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=pass mongo --tlsMode requireTLS --tlsCertificateKeyFile /ssl/fullchain-key.pem --tlsCAFile /etc/ssl/certs/ISRG_Root_X1.pem
fullchain-key.pem is 'cat fullchain.pem privkey.pem > fullchain-key.pem'
docker name or server name must match certificate name
For Compass I use:
The server has it's own certificate and compass as well.

Couldn't connect to server apollo.modulusmongo.net

I'm trying to connect MongoDB database on modulus.io by referencing [this][1] tutorial.
I've registered with modules .io and received the database url. (Modulus provides the database URL you need and you can use mongoose.connect to connect to it)
i.e.
MONGO URI
mongodb://<user>:<pass>#apollo.modulusmongo.net:27017/wIp4otyd
MONGO CONSOLE
mongo apollo.modulusmongo.net:27017/wIp4otyd -u <user> -p <pass>
But when I'm trying to connect it through both node.js and console its showing me following error:
C:\mongodb\bin>mongo apollo.modulusmongo.net:27017/wIp4otyd -u <my_uname> -p <my_pwd>
2016-02-04T12:01:07.097+0530 I CONTROL [main] Hotfix KB2731284 or later update is installed, no need to zero-out data files
MongoDB shell version: 3.2.1
connecting to: apollo.modulusmongo.net:27017/wIp4otyd
2016-02-04T12:01:09.455+0530 W NETWORK [thread1] Failed to connect to 52.6.181.208:27017, reason: errno:10061 No connection could be made because the target ma
chine actively refused it.
2016-02-04T12:01:09.457+0530 E QUERY [thread1] Error: couldn't connect to server apollo.modulusmongo.net:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:226:14
#(connect):1:6
exception: connect failed
Its connecting to local perfectly (mongoose.connect('mongodb://localhost/news');)
but refusing to modulus.io (mongoose.connect('mongodb://<my_uname>:<my_pwd>#apollo.modulusmongo.net:27017/wIp4otyd');)

Whats wrong with my Mongo query?

I've recently set a path in my vi .bash_profile to my mongo commands. I know this works because it was working yesterday.
However when I do it now I get this error:
AMAC02MX3APF8J3:~ james.flan$ mongo
MongoDB shell version: 3.0.3
connecting to: test
2015-05-19T11:34:58.708+0100 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-05-19T11:34:58.710+0100 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
Here is the content in my vi .bash_profile:
alias mongod="mongod --dbpath /Users/ryan.garrett/Documents/Software/MongoDB/data"
export PATH="/Users/ryan.garrett/Documents/Software/MongoDB/bin:$PATH"
Can someone please tell me how to connect to the server?
Check your /etc/hosts for localhost entry and also make sure that mongod is listening to all interfaces, you can check by netstat -an|grep mongo.