title: MongoDB GSSAPI Authentication failing on LINUX RHEL7 with .NET Core 2.1
body: <p>I am currently running a dockerized c# .NET Core 2.1 application on Linux.</p>
  <p>My application connects to Mongo on windows using CreateGssapiCredential and works as expected.</p>
  <p>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 -</p>
  <pre><code>{
          &quot;ClassName&quot;: &quot;System.DllNotFoundException&quot;,
          &quot;Message&quot;: &quot;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&quot;,
          &quot;Data&quot;: null,
          &quot;InnerException&quot;: null,
          &quot;HelpURL&quot;: null,
          &quot;StackTraceString&quot;: &quot;   at MongoDB.Driver.Core.Authentication.Sspi.NativeMethods.AcquireCredentialsHandle(String principal, String package, SecurityCredentialUse credentialUsage, IntPtr logonId, IntPtr identity, Int32 keyCallback, IntPtr keyArgument, SspiHandle&amp; credentialHandle, Int64&amp; 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)&quot;,
          &quot;RemoteStackTraceString&quot;: null,
          &quot;RemoteStackIndex&quot;: 0,
          &quot;ExceptionMethod&quot;: null,
          &quot;HResult&quot;: -2146233052,
          &quot;Source&quot;: &quot;MongoDB.Driver.Core&quot;,
          &quot;WatsonBuckets&quot;: null,
          &quot;TypeLoadClassName&quot;: null,
          &quot;TypeLoadAssemblyName&quot;: null,
          &quot;TypeLoadMessageArg&quot;: null,
          &quot;TypeLoadResourceID&quot;: 0
      }
  </code></pre>
  <p>I followed the documentation here for linux - <a href="https://mongodb-documentation.readthedocs.io/en/latest/ecosystem/tutorial/authenticate-with-csharp-driver.html#linux-systems&amp;gsc.tab=0" rel="nofollow noreferrer">https://mongodb-documentation.readthedocs.io/en/latest/ecosystem/tutorial/authenticate-with-csharp-driver.html#linux-systems&amp;gsc.tab=0</a></p>
  <p>and also the GSSAPI/Kerberos documentation here - <a href="https://github.com/mongodb/mongo-csharp-driver/blob/master/Docs/reference/content/reference/driver/authentication.md" rel="nofollow noreferrer">https://github.com/mongodb/mongo-csharp-driver/blob/master/Docs/reference/content/reference/driver/authentication.md</a></p>
  <p>This is the code that sets the connection -</p>
  <pre><code>var settings = new MongoClientSettings
              {
                  Credential = MongoCredential.CreateGssapiCredential(test@testdomain.com)
                  .WithMechanismProperty(&quot;CANONICALIZE_HOST_NAME&quot;, canonicalizeHostName),
                  Servers = servers.Split(',').Select(s =&gt; new MongoServerAddress(s, port))
              };
  
              Database = new MongoClient(settings).GetDatabase(databaseName);
  
              _collectionName = collectionName ?? typeof(T).Name;
              _collection = Database.GetCollection&lt;T&gt;(collectionName);
  </code></pre>
  <p>Nothing seems to fix the problem. How do i get this .NET core 2.1 app to work in linux with GSSAPI?</p>