nightroman / Mdbc

MongoDB Cmdlets for PowerShell
Apache License 2.0
141 stars 16 forks source link

TLS connection not possible? #53

Closed rccvilla closed 3 years ago

rccvilla commented 3 years ago

I've configured mongodb to preferTLS, in my tests, and will switch to requireTLS on production, but I cannot connect to mongodb with TLS. Tried:

Connect-Mdbc -ConnectionString "mongodb://user:password@server/" $db = Get-MdbcDatabase test $collection = Get-MdbcCollection test-collection -Database $db Get-MdbcData -Collection $collection -As PS | Format-Table

Everything OK, but when I add "?tls=true" on ConnectionString... Connect-Mdbc -ConnectionString "mongodb://user:password@server/?tls=true" Then I got an exception...

Get-MdbcData: /workspaces/mongodb-test/tmp/test.ps1:8:1
Line |
   8 |  Get-MdbcData -Collection $collection -As PS | Format-Table
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception has been thrown by the target of an invocation

Connecting to mongodb using TLS not possible?

nightroman commented 3 years ago

Hmm, I do not really know, Mdbc just uses the C# driver and passes the connection string in there. Maybe you should ask at C# driver or MongoDB forums.

But before doing this, in a clean session, after getting this error, can you examine all errors in $Error? And dive deeper into these errors, like what was the "Exception has been thrown by the target of an invocation" exactly?

nightroman commented 3 years ago

Can you connect using your connection string and mongo shell?

rccvilla commented 3 years ago

Can you connect using your connection string and mongo shell?

Yeah. With mongo shell and with python

rccvilla commented 3 years ago

Hmm, I do not really know, Mdbc just uses the C# driver and passes the connection string in there. Maybe you should ask at C# driver or MongoDB forums.

But before doing this, in a clean session, after getting this error, can you examine all errors in $Error? And dive deeper into these errors, like what was the "Exception has been thrown by the target of an invocation" exactly?

$Error

Get-MdbcData: Exception has been thrown by the target of an invocation.
rccvilla commented 3 years ago

Nevermind, will try a different approach