Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
13.5
Statistic
FMM
Blog
Sets the TLS (SSL) options to use when connecting to TLS enabled MongoDB servers.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
MongoDB | 13.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
MongoDBRef | The reference number for the mongo connection. | $MongoDB | |
ClientCertificateKeyFile | The native path to the PEM file with the private key to use. | ||
ClientCertificateKeyPassword | The password for the PEM file with private key. | ||
CertificateAuthorityFile | The native file path for a CA file. e.g. get such a file from CURL website: https://curl.se/docs/caextract.html |
||
CertificateAuthorityDirectory | The native file path to the CA directory. | Optional | |
CertificateRevocationListFile | The native file path to the Certificate revocation list file. | Optional | |
AllowInvalidCertificates | Whether to do weaker certificate validation. Pass 1 to enable or 0 to disable. Default is 0 to disallow. |
0 | Optional |
AllowInvalidHostnames | Whether to allow invalid host names. Pass 1 to enable or 0 to disable. Default is 0 to disallow. This allows you to disable hostname validation to allow to continue if the hostname doesn't match the certificate. |
0 | Optional |
Returns OK or error.
Connect via certificate:
Set Variable [ $Mongo ; Value: MBS( "MongoDB.New" ) ]
If [ MBS("IsError") ]
Show Custom Dialog [ "Failed to create new MongoDB o…" ; $Mongo ]
Exit Script [ Text Result: ]
End If
#
# set URL with authentication via certificate
Set Variable [ $r ; Value: MBS( "MongoDB.SetURI"; $Mongo; "mongodb://localhost/?tls=true" ) ]
If [ MBS("IsError") ]
Set Variable [ $x ; Value: MBS( "MongoDB.Release"; $Mongo ) ]
Show Custom Dialog [ "Failed to parse connection str…" ; $r ]
Exit Script [ Text Result: ]
End If
#
# specify where to find keys
Set Variable [ $r ; Value: MBS( "MongoDB.SetSSLOptions"; $Mongo; "/Users/cs/Desktop/key.pem"; "test123"; "/Users/cs/Desktop/cacert.pem" ) ]
Set Variable [ $r ; Value: MBS( "MongoDB.SetAuthMechanism"; $Mongo; "MONGODB-X509" ) ]
#
# now connect
Set Variable [ $r ; Value: MBS( "MongoDB.Connect"; $Mongo) ]
If [ MBS("IsError") ]
Set Variable [ $x ; Value: MBS( "MongoDB.Release"; $Mongo ) ]
Show Custom Dialog [ "Failed to connect to MongoDB." ; $r ]
Exit Script [ Text Result: ]
End If
This function checks for a license.
Created 18th July 2023, last changed 7th August 2023