Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3228

Percent-encoded authSource in mongodb+srv connection string fails for MONGODB-AWS and GSSAPI

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.11.5
    • Affects Version/s: 2.11.2
    • Component/s: Connectivity
    • Labels:
      None
    • Fully Compatible

      Consider the following code snippet:

      var uri = "mongodb+srv://AWS_KEY:AWS_PRIVATE_KEY@cluster441.ebdql.mongodb.net/<dbname>?authMechanism=MONGODB-AWS&authSource=%24external&retryWrites=true&w=majority";
      var mongoURL = new MongoUrl(uri);
      var client = new MongoClient(mongoURL);
      Console.WriteLine("Finished!");
      

      Construction of the MongoClient instance fails with the following stack trace:

      Unhandled Exception: System.ArgumentException: A MONGODB-AWS source must be $external.
      Parameter name: source
         at MongoDB.Driver.MongoCredential.EnsureNullOrExternalSource(String mechanism, String source)
         at MongoDB.Driver.MongoCredential.FromComponents(String mechanism, String source, String databaseName, String username, MongoIdentityEvidence evidence)
         at MongoDB.Driver.MongoClientSettings.FromUrl(MongoUrl url)
         at MongoDB.Driver.MongoClient..ctor(MongoUrl url)
         at tour.Program.Main(String[] args) in /shared/csharp/Program.cs:line 14
      

      If we change authSource=%24external to authSource=$external, the code works as expected. If we change the scheme from mongodb+srv:// to mongodb:// (and switched to the correct hostnames), it also works as expected.

            Assignee:
            james.kovacs@mongodb.com James Kovacs
            Reporter:
            james.kovacs@mongodb.com James Kovacs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: