terminate called after throwing an instance of 'mongo::UserException'
what(): SCRAM-SHA-1 mechanism support not compiled into client library. (Some mechanisms require the driver be compiled with the flags --ssl or --use-sasl-client)
sudo scons -j 4 --disable-warnings-as-errors --c++11=on --ssl --sharedclient --prefix=/opt/mongo-client install
mongo::DBClientConnection conn;
std::string url = host + ":" + port;
//Connect to database
conn.connect(url);
conn.auth(dbname,user,password,errmsg, true);
conn.auth( BSON(
"user" << user <<
"pwd" << password <<
"mechanism" << "SCRAM-SHA-1" <<
"db" << dbname ) );
sudo scons -j 4 —disable-warnings-as-errors —c++11=on —ssl —sharedclient —prefix=/opt/mongo-client install
Hi Guillermo,
I compiled the legacy branch with the same options as you have and tested it with success. I used Ubuntu 14.04 and MongoDB v3.2.1 for the test.
The test code is also similar to yours:
mongo::client::initialize();
mongo::DBClientConnection c;
try {
c.connect("localhost");
mongo::BSONObj params = BSON("mechanism" << "SCRAM-SHA-1" << "user" << "myuser" << "db" << "database" << "pwd" << "mypwd");
c.auth(params);
} catch( const mongo::DBException &e ) {
std::cout << "caught " << e.what() << std::endl;
}
std::auto_ptr<mongo::DBClientCursor> cursor = c.query( "database.collection", mongo::BSONObj());
while(cursor->more()){
std::cout << cursor->next().toString() << std::endl;
}
Did you have an existing include and library files that were compiled without --ssl
? Perhaps it was linked incorrectly at your code compilation time ?
Also, could you provide the following information :
Regards,
Wan.