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 amongoc_client_pool_t. instead, callmongoc_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: Amongoc_client_t.opts: Amongoc_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
π COPYRIGHT π
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
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms