Enes Köroğlu
Enes Köroğlu

Reputation: 184

MongoDB Connection Error

When i try to connect to mongodb (after setting Database, Username, Password, Server and Port values) with FDConnection i get [FireDAC][Phys][Mongo]The authentication mechanism "SCRAM-SHA-1" is not supported.. error.

If I set UseSSL option to True and try again this time I get [FireDAC][Phys][Mongo]SSL is not enabled in this build of mongo-c-driver.. error.

In the same computer I can connect to MongoDB with MongoBooster (with Basic Authentication)

Upvotes: 0

Views: 3582

Answers (1)

Victoria
Victoria

Reputation: 7912

SCRAM-SHA-1 authentication mechanism

Upgrade to the latest mongo-c-driver (or at least version 1.1.0) because the one you use does not support SCRAM-SHA-1 authentication mechanism (which is what the driver exception says). And since it was introduced and became default authentication mechanism in MongoDB 3.0, you must be using old driver against new DBMS.

MONGODB-CR authentication mechanism

Upgrade to the latest mongo-c-driver (or at least version 1.1.0) for reason desribed above. Since MONGODB-CR is no longer default authentication mechanism, you need to explicitly specify it by setting authMechanism to MONGODB-CR.

So if you want basic authentication, you need to specify this in the MongoAdvanced parameter:

...
FDConnection1.Params.Add('MongoAdvanced=authMechanism=MONGODB-CR');
FDConnection1.Connected := True;

Evidence about outdated driver

Following links point to corresponding source code lines where you can find evidence about your outdated driver:

  • version 1.0.2 - The authentication mechanism "SCRAM-SHA-1" is not supported message will be returned due to missing SCRAM-SHA-1 mechanism.

  • version 1.1.0 - no such message will be shown, because SCRAM-SHA-1 mechanism exists.

  • version 1.6.3 - in current version, the message sounds Unknown authentication mechanism.

So, that message The authentication mechanism "SCRAM-SHA-1" is not supported you can get with driver version older than 1.1.0. Build the driver from the latest stable source and set the library path to the VendorLib property of your physical driver link component.

Something like this (don't be confused by the version in the library name, authors keep it outdated, but it may change in the future):

FDPhysMongoDriverLink1.VendorLib := 'C:\PathToDriver\libmongoc-1.0.dll';

Upvotes: 2

Related Questions