Mongodb – How to perform a mongoimport to a host that requires an SSL Certificate

certificateimportmongodbssl

I am trying to load some sample JSON data into a MongoDB database (hosted on IBM Bluemix).

The connection requires SSL, and a SSL Certificate has been provided, but I keep getting an error when I run mongoimport from the terminal (OS X).

Here is the command I am running (with sensitive data removed, of course):

mongoimport --ssl --sslAllowInvalidCertificates --host=<host_address>:<port>/admin -u <username> -p <password> --drop --file ./sample-dataset.json --db test --collection testColl --sslPEMKeyFile ./SSLCert.pem

And the error I receive:

Failed: error connecting to db server: no reachable servers, openssl error: dial tcp <host>:<port> getsockopt: connection refused

I'm new to SSL, especially when it comes to MongoDB. Am I just not using the right options/config for mongoimport?

Best Answer

With mongoimport you must separate host address and authentication DB

--host host_address:port --authenticationDatabase admin