Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MongoDB.SetSSLOptions

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
MBS( "MongoDB.SetSSLOptions"; MongoDBRef; ClientCertificateKeyFile; ClientCertificateKeyPassword; CertificateAuthorityFile { ; CertificateAuthorityDirectory; CertificateRevocationListFile; AllowInvalidCertificates; AllowInvalidHostnames } )   More

Parameters

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

Result

Returns OK or error.

Description

Sets the TLS (SSL) options to use when connecting to TLS enabled MongoDB servers.
A call to MongoDB.SetSSLOptions overrides all TLS options set through the connection string with which the client was constructed.
All texts can be empty if needed.

See Files.DeleteLater to delete a temporary key file when FileMaker quits.

Examples

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

See also

Release notes

Blog Entries

This function checks for a license.

Created 18th July 2023, last changed 7th August 2023


MongoDB.SetPassword - MongoDB.SetURI