I'm using the C++ (releases/stable as of this morning) driver. I write this:
mongocxx::instance instance{};
mongocxx::uri uri("mongodb://my_user:password@localhost:27017/?ssl=true");
mongocxx::options::client client_options;
mongocxx::options::ssl ssl_options;
ssl_options.allow_invalid_certificates(true);
client_options.ssl_opts(ssl_options);
mongocxx::client client(uri, client_options);
mongocxx::database db = client["my_database"];
mongocxx::collection spines = db["spines"];
{
mongocxx::cursor cursor = spines.find(document{} << finalize);
cout << "This happens." << endl;
for (auto doc : cursor) {
cout << "This doesn't happen." << endl;
cout << bsoncxx::to_json(doc) << endl;
}
}
Somewhere between the two comments ("this happens" and "this doesn't happen"), the program crashes with this message:
terminate called after throwing an instance of 'mongocxx::v_noabi::query_exception'
what(): auth failed: generic server error
Aborted (core dumped)
and the mongo log shows this:
2017-11-16T17:51:34.957+0000 [initandlisten] connection accepted from 1.2.3.4:42196 #1430800 (27 connections now open)
2017-11-16T17:51:35.420+0000 [conn1430800] authenticate db: admin { authenticate: 1, user: "my_user", nonce: "xxx", key: "xxx" }
2017-11-16T17:51:35.421+0000 [conn1430800] Failed to authenticate my_database@admin with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user my_database@admin
2017-11-16T17:51:35.528+0000 [conn1430800] end connection 1.2.3.4:42196 (26 connections now open)
Those credentials work from the commandline client.
I'm pretty confused why I'm seeing this error about admin. Anyone see what I'm missing?