I am currently running a dockerized c# .NET Core 2.1 application on Linux.
My application connects to Mongo on windows using CreateGssapiCredential and works as expected.
When I try to run the same app in linux it fails with the error “An exception occurred while opening a connection to the server.”. Stack trace -
{
"ClassName": "System.DllNotFoundException",
"Message": "Unable to load shared library 'security.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libsecurity.dll: cannot open shared object file: No such file or directory",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at MongoDB.Driver.Core.Authentication.Sspi.NativeMethods.AcquireCredentialsHandle(String principal, String package, SecurityCredentialUse credentialUsage, IntPtr logonId, IntPtr identity, Int32 keyCallback, IntPtr keyArgument, SspiHandle& credentialHandle, Int64& timestamp)\n at MongoDB.Driver.Core.Authentication.Sspi.SecurityCredential.Acquire(SspiPackage package, String username, SecureString password)\n at MongoDB.Driver.Core.Authentication.GssapiAuthenticator.FirstStep..ctor(String serviceName, String hostName, String realm, String username, SecureString password, SaslConversation conversation)\n at MongoDB.Driver.Core.Authentication.GssapiAuthenticator.GssapiMechanism.Initialize(IConnection connection, SaslConversation conversation, ConnectionDescription description)\n at MongoDB.Driver.Core.Authentication.SaslAuthenticator.Authenticate(IConnection connection, ConnectionDescription description, CancellationToken cancellationToken)\n at MongoDB.Driver.Core.Authentication.AuthenticationHelper.Authenticate(IConnection connection, ConnectionDescription description, IReadOnlyList`1 authenticators, CancellationToken cancellationToken)\n at MongoDB.Driver.Core.Connections.ConnectionInitializer.InitializeConnection(IConnection connection, CancellationToken cancellationToken)\n at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2146233052,
"Source": "MongoDB.Driver.Core",
"WatsonBuckets": null,
"TypeLoadClassName": null,
"TypeLoadAssemblyName": null,
"TypeLoadMessageArg": null,
"TypeLoadResourceID": 0
}
I followed the documentation here for linux - Authenticate to MongoDB with the C# Driver — MongoDB Manual
and also the GSSAPI/Kerberos documentation here - mongo-csharp-driver/authentication.md at master · mongodb/mongo-csharp-driver · GitHub
This is the code that sets the connection -
var settings = new MongoClientSettings
{
Credential = MongoCredential.CreateGssapiCredential(test@testdomain.com)
.WithMechanismProperty("CANONICALIZE_HOST_NAME", canonicalizeHostName),
Servers = servers.Split(',').Select(s => new MongoServerAddress(s, port))
};
Database = new MongoClient(settings).GetDatabase(databaseName);
_collectionName = collectionName ?? typeof(T).Name;
_collection = Database.GetCollection<T>(collectionName);
Nothing seems to fix the problem. How do i get this .NET core 2.1 app to work in linux with GSSAPI?