MONGOC_AUTO_EN...S_SET_TLS_OPTS(3)

πŸ’… MONGOC_AUTO_EN...S_SET_TLS_OPTS(3) β€” like, the TLS options one

okay bestie, so this is a page straight out of libmongoc (that's the MongoDB C driver, iykyk) and it's all about one little function that hands your auto-encryption setup a whole BSON doc full of TLS config. slay. let's get into it ✨


✨ SYNOPSIS ✨

void
mongoc_auto_encryption_opts_set_tls_opts (
   mongoc_auto_encryption_opts_t *opts, const bson_t *tls_opts);

it returns void, so no exit-status drama here β€” it just does the thing and dips. 🫢


πŸŽ€ PARAMETERS πŸŽ€

  • opts β€” the mongoc_auto_encryption_opts_t. yeah. the auto encryption opts. the main character. πŸ‘‘
  • tls_opts β€” a bson_t that maps a Key Management Service (KMS) provider to a BSON document stuffed with TLS options. that's the whole vibe check.

so tls_opts is a BSON document shaped exactly like this:

<KMS provider>: {
   tlsCaFile: Optional<String>
   tlsCertificateKeyFile: Optional<String>
   tlsCertificateKeyFilePassword: Optional<String>
}

and the KMS providers that are supported as keys in the tls_opts document are aws, azure, gcp, and kmip. no cap. πŸ¦‹

they can also carry an optional name suffix, separated with a colon. example: aws:name2. cute little nickname energy, honestly πŸ’…

so yeah β€” tls_opts maps the KMS provider name to a BSON document for TLS options. that's the whole relationship, they're literally matched up.

the BSON document for TLS options may contain the following keys:

  • MONGOC_URI_TLSCERTIFICATEKEYFILE
  • MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD
  • MONGOC_URI_TLSCAFILE

those are the three, exactly those three, don't go inventing a fourth one on me πŸ™ˆ


🌸 Example use 🌸

here's the iconic example, verbatim, no notes:

mongoc_auto_encryption_opts_t *ae_opts = mongoc_auto_encryption_opts_new();
bson_t *tls_opts = bson_new();

BCON_APPEND(tls_opts, "kmip", "{", MONGOC_URI_TLSCAFILE, "ca1.pem", "}");
BCON_APPEND(tls_opts, "aws", "{", MONGOC_URI_TLSCAFILE, "ca2.pem", "}");
mongoc_auto_encryption_opts_set_tls_opts(ae_opts, tls_opts);

see how it's done? kmip gets ca1.pem, aws gets ca2.pem, and then the whole thing gets yeeted into mongoc_auto_encryption_opts_set_tls_opts(). ate. πŸ”₯

for a description of the behavior of these options, go see Configuring TLS. that's where the actual behavioural tea is spilled β€” this page is just handing you the plumbing, fr fr.

⭐ SEE ALSO: ⭐

  • mongoc_client_enable_auto_encryption()
  • In-Use Encryption

those are your next stops, bestie, go read them, i'm literally begging 🫢


πŸ’œ AUTHOR πŸ’œ

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the whole page, mwah πŸ’‹. quick sign-off: this lil masterpiece is from libmongoc version 2.5.6, dated Oct 09, 202 β€” and yes the year is literally cut off mid-number in the footer, the manpage gremlins got hungry, don't @ me 😭. anyway slay, go encrypt something. πŸŽ€

πŸ“¦ where this page comes from