I am developing an ADFS plugin that connects to Mongo via the MongoDB Driver. This requires the libraries to be installed in the GAC, and and ran into two issues:
First one, the official driver available in nuget is not signed. This can easily be resolved by searching for and running an unofficial unsigned build from nuget, which we have.
Second one - this where I’m stuck:
I am running this on Windows Server 2016 with .net 4.8 installed. When the plugin code calls the MongoDB Driver to make a connection - the following error is thrown:
Code Snippet:
_mongoClientSettings = MongoClientSettings.FromConnectionString($“mongodb+srv://{_DBEndPoint}/{_DBNameMFA}?authSource=$external&authMechanism=MONGODB-X509&retryWrites=true&w=majority”);
Exception:
DnsClient.DnsResponseException: Query 4162 => api-dev.xdqkf.mongodb.net IN TXT on 10.118.2.239:53 failed with an error. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
at DnsClient.Internal.PooledBytes..ctor(Int32 length)
at DnsClient.DnsDatagramWriter..ctor()
at DnsClient.DnsUdpMessageHandler.Query(IPEndPoint server, DnsRequestMessage request, TimeSpan timeout)
at DnsClient.LookupClient.ResolveQuery(IReadOnlyList`1 servers, DnsQuerySettings settings, DnsMessageHandler handler, DnsRequestMessage request, LookupClientAudit audit)
--- End of inner exception stack trace ---
at DnsClient.LookupClient.ResolveQuery(IReadOnlyList`1 servers, DnsQuerySettings settings, DnsMessageHandler handler, DnsRequestMessage request, LookupClientAudit audit)
at DnsClient.LookupClient.QueryInternal(DnsQuestion question, DnsQuerySettings queryOptions, IReadOnlyCollection`1 servers)
at MongoDB.Driver.Core.Configuration.ConnectionString.Resolve(Boolean resolveHosts)
at MongoDB.Driver.MongoUrl.Resolve(Boolean resolveHosts)
at MongoDB.Driver.MongoClientSettings.FromUrl(MongoUrl url)
The MongoDB Driver is looking for System.Buffers 4.0.2.0, but the version installed is 4.0.3.0, and as it’s in the same .net major version (4.x), there doesn’t seem to be a way to have both versions side by side…
Today, I’m going to try to rebuild the driver from github - which might allow us to regartet the .net version its built on and also allow us to sign it ourselves.
Thanks,
Abraham