MONGOC_CLIENT_SET_SSL_OPTS(3)

πŸ’… MONGOC_CLIENT_SET_SSL_OPTS πŸ’…

okay so bestie, this is a page from libmongoc (the MongoDB C driver) and it's all about mongoc_client_set_ssl_opts β€” the function that tells your client how to do the secure-connection thing. it's giving "lock the door behind you" energy, and honestly we love that for us πŸ”βœ¨

✨ SYNOPSIS ✨

#ifdef MONGOC_ENABLE_SSL
void
mongoc_client_set_ssl_opts (mongoc_client_t *client,
                            const mongoc_ssl_opt_t *opts);
#endif
NOTE: okay heads up 🫢 β€” even though some API names toss around the word "ssl", the C driver only supports TLS protocols, which supersede SSL. so like, the naming is a little vintage, but TLS is the main character here. periodt.

🌸 DESCRIPTION 🌸

This is the function you call to set the TLS (SSL) options to use when connecting to TLS enabled MongoDB servers. secure vibes only, no cap πŸ’–

Now here's the part that's lowkey iconic: the mongoc_ssl_opt_t struct gets copied by the client, along with the strings it points to β€” that's pem_file, pem_pwd, ca_file, ca_dir, and crl_file β€” so those don't have to remain valid after the call to mongoc_client_set_ssl_opts(). meaning you can free your stuff afterwards and the client is still holding its own little copy. so considerate, honestly πŸŽ€

Also, a call to mongoc_client_set_ssl_opts() overrides all TLS options that were set through the connection string with which the mongoc_client_t was constructed. like, this call said "i'm the captain now" and took over 🌈

⚠️ and now the serious bit, bestie: it is a programming error to call this function on a client from a mongoc_client_pool_t. instead, call mongoc_client_pool_set_ssl_opts() on the pool before popping any clients. do not come for the pool clients directly, they are not ready πŸ’€

Changed in version 2.0.0: this function logs an error and immediately returns if client is from a mongoc_client_pool_t. previously, this function unsafely applied the options to the pooled client. so yeah β€” glow-up era, the old behavior was giving chaos πŸ™ˆ

⭐ PARAMETERS ⭐

  • client: A mongoc_client_t.
  • opts: A mongoc_ssl_opt_t.

πŸ’œ AVAILABILITY πŸ’œ

This feature requires that the MongoDB C driver was compiled with -DENABLE_SSL. no flag, no feature β€” that's just how it is 🫢

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the whole thing, bestie β€” you ate that πŸ’…βœ¨ okay so the source/version vibes for this page: it's from libmongoc 2.5.6, dated Oct 09, 2026 β€” go forth and TLS responsibly, mwah πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from