Skip to content

Commit da7d78d

Browse files
committed
update docs on _parse_all_tls_opts and _parse_one_tls_opts
1 parent 2f8aa6a commit da7d78d

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/libmongoc/src/mongoc/mongoc-crypt.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,10 @@ _state_machine_run (_state_machine_t *state_machine,
675675
return ret;
676676
}
677677

678+
/* _parse_one_tls_opts parses one TLS document.
679+
* @iter is an iterator at the start of a KMS provider key/value pair.
680+
* @out_opt is written to on success, and left unmodified on error.
681+
* Returns false and sets @error on error. */
678682
static bool
679683
_parse_one_tls_opts (bson_iter_t *iter,
680684
mongoc_ssl_opt_t *out_opt,
@@ -749,6 +753,12 @@ _parse_one_tls_opts (bson_iter_t *iter,
749753
return ok;
750754
}
751755

756+
/* _parse_all_tls_opts initializes TLS options for all KMS providers.
757+
* @tls_opts is the BSON document passed through
758+
* mongoc_client_encryption_opts_set_tls_opts or
759+
* mongoc_auto_encryption_opts_set_tls_opts.
760+
* Defaults to using mongoc_ssl_opt_get_default() if options are not passed for
761+
* a provider. Returns false and sets @error on error. */
752762
static bool
753763
_parse_all_tls_opts (_mongoc_crypt_t *crypt,
754764
const bson_t *tls_opts,
@@ -757,18 +767,6 @@ _parse_all_tls_opts (_mongoc_crypt_t *crypt,
757767
bson_iter_t iter;
758768
bool ok = false;
759769

760-
if (!tls_opts) {
761-
return true;
762-
}
763-
764-
if (!bson_iter_init (&iter, tls_opts)) {
765-
bson_set_error (error,
766-
MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION,
767-
MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG,
768-
"Error starting iteration of TLS options");
769-
goto fail;
770-
}
771-
772770
_mongoc_ssl_opts_copy_to (mongoc_ssl_opt_get_default (),
773771
&crypt->aws_tls_opt,
774772
false /* copy internal */);
@@ -785,6 +783,17 @@ _parse_all_tls_opts (_mongoc_crypt_t *crypt,
785783
&crypt->kmip_tls_opt,
786784
false /* copy internal */);
787785

786+
if (!tls_opts) {
787+
return true;
788+
}
789+
790+
if (!bson_iter_init (&iter, tls_opts)) {
791+
bson_set_error (error,
792+
MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION,
793+
MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG,
794+
"Error starting iteration of TLS options");
795+
goto fail;
796+
}
788797

789798
while (bson_iter_next (&iter)) {
790799
const char *key;

0 commit comments

Comments
 (0)