1

When I'm trying to import json to my MongoDB which is password authenticated, encrypted and TLS/SSL based connection, I'm getting error.

This is the mongoImport Im writting:

mongoimport --verbose --ssl --sslCAFile "C:\server\cert\rootCA.pem" --sslPEMKeyFile "C:\server\cert\server.pem" --sslFIPSMode --host 127.0.0.1 --port 27017 --username databaseAdmin --password password123 --authenticationDatabase admin --db test_coll --collection blocks --file "C:\data\blocks.json"

And I got the following error message:

2018-07-20T15:21:27.365+0530    filesize: 6392 bytes
2018-07-20T15:21:27.366+0530    using fields:
2018-07-20T15:21:30.368+0530    [........................] test_coll.blocks
        0B/6.24KB (0.0%)
2018-07-20T15:21:30.928+0530    [........................] test_coll.blocks
        0B/6.24KB (0.0%)
2018-07-20T15:21:30.928+0530    Failed: error connecting to db server: no reachable servers, openssl error: Host validation error
2018-07-20T15:21:30.928+0530    imported 0 documents
Temp O'rary
  • 5,366
  • 13
  • 49
  • 109
  • I faced the same error but without the openssl error - reference to thread and solutions: https://stackoverflow.com/questions/32195997/mongodb-failed-error-connecting-to-db-server-no-reachable-servers/61164443#61164443 – Rot-man Apr 11 '20 at 22:20

1 Answers1

0

Hostname in their certificates should match the specified hostname. So, I updated my hostname to localhost.

Now, my mongoimport command looks like:

mongoimport --verbose --ssl --sslCAFile "C:\server\cert\rootCA.pem" --sslPEMKeyFile "C:\server\cert\server.pem" --sslFIPSMode --host localhost --port 27017 --username databaseAdmin --password password123 --authenticationDatabase admin --db test_coll --collection blocks --file "C:\data\blocks.json"

And now it works.

Temp O'rary
  • 5,366
  • 13
  • 49
  • 109