Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-2201

Getting "could not start SASLPrep for password" when connecting with user name/password

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu 20.04, MongoDB V4.4 with access control, Driver V3.6.2

      I have a mongDB V4.4 running in my VM (Ubuntu 20.04) in access control mode. I created an admin user with this role:
      roles: [ { role: “root”, db: “admin” } ]

      I installed the mongoDB driver for C++ (V3.6.2) and wrote a mini-program to test it. My code (basically copied from mongocxx tutorial):

      mongocxx::instance instance{};

      mongocxx::uri uri( "mongodb://userName:password@localhost:27017/?authSource=admin");

      mongocxx::client conn(uri);

      mongocxx::database db = conn["test"];

      mongocxx::collection coll = db["test"];

      mongocxx::cursor cursor = coll.find({});

      for (auto doc : cursor)

      {    std::cout << bsoncxx::to_json(doc) << "\n"; }

       

      I inserted a document in test.test from mongo shell. The ‘find’ command works with the same user in mongo shell. When running this mini program I get:

       terminate called after throwing an instance of 'mongocxx::v_noabi::query_exception' what(): could not start SASLPrep for password: generic server error Aborted (core dumped)

      When I cancel the MonogDB access control and connect to it with the same lines but without the user/password it works great and I can insert and find documents.
      I also installed Compass and copied the connection string from above in order to connect to MongoDB from it. It worked fine and I was able to read/write/delete and so on.

        1. noname
          3 kB
          Shavit Talman
        2. noname
          3 kB
          Shavit Talman

            Assignee:
            roberto.sanchez@mongodb.com Roberto Sanchez
            Reporter:
            shavitalman@gmail.com Shavit Talman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: