@@ -362,8 +362,10 @@ typedef struct {
362
362
/**
363
363
* @brief Attempt to open the CSFLE dynamic library and initialize a vtable for
364
364
* it.
365
+ *
366
+ * @param status is an optional status to set an error message if `mcr_dll_open` fails.
365
367
*/
366
- static _loaded_csfle _try_load_csfle (const char * filepath , _mongocrypt_log_t * log ) {
368
+ static _loaded_csfle _try_load_csfle (const char * filepath , _mongocrypt_log_t * log , mongocrypt_status_t * status ) {
367
369
// Try to open the dynamic lib
368
370
mcr_dll lib = mcr_dll_open (filepath );
369
371
// Check for errors, which are represented by strings
@@ -374,6 +376,7 @@ static _loaded_csfle _try_load_csfle(const char *filepath, _mongocrypt_log_t *lo
374
376
"Error while opening candidate for CSFLE dynamic library [%s]: %s" ,
375
377
filepath ,
376
378
lib .error_string .data );
379
+ CLIENT_ERR ("Error while opening candidate for CSFLE dynamic library [%s]: %s" , filepath , lib .error_string .data );
377
380
// Free resources, which will include the error string
378
381
mcr_dll_close (lib );
379
382
// Bad:
@@ -476,7 +479,7 @@ static _loaded_csfle _try_find_csfle(mongocrypt_t *crypt) {
476
479
// Do not allow a plain filename to go through, as that will cause the
477
480
// DLL load to search the system.
478
481
mstr_assign (& csfle_cand_filepath , mpath_absolute (csfle_cand_filepath .view , MPATH_NATIVE ));
479
- candidate_csfle = _try_load_csfle (csfle_cand_filepath .data , & crypt -> log );
482
+ candidate_csfle = _try_load_csfle (csfle_cand_filepath .data , & crypt -> log , crypt -> status );
480
483
}
481
484
} else {
482
485
// No override path was specified, so try to find it on the provided
@@ -498,7 +501,7 @@ static _loaded_csfle _try_find_csfle(mongocrypt_t *crypt) {
498
501
}
499
502
}
500
503
// Try to load the file:
501
- candidate_csfle = _try_load_csfle (csfle_cand_filepath .data , & crypt -> log );
504
+ candidate_csfle = _try_load_csfle (csfle_cand_filepath .data , & crypt -> log , NULL /* status */ );
502
505
if (candidate_csfle .okay ) {
503
506
// Stop searching:
504
507
break ;
@@ -817,9 +820,11 @@ static bool _try_enable_csfle(mongocrypt_t *crypt) {
817
820
// If a crypt_shared override path was specified, but we did not succeed in
818
821
// loading crypt_shared, that is a hard-error.
819
822
if (crypt -> opts .crypt_shared_lib_override_path .data && !found .okay ) {
820
- CLIENT_ERR ("A crypt_shared override path was specified [%s], but we failed to "
821
- "open a dynamic library at that location" ,
822
- crypt -> opts .crypt_shared_lib_override_path .data );
823
+ // Wrap error with additional information.
824
+ CLIENT_ERR ("A crypt_shared override path was specified [%s], but we failed to open a dynamic "
825
+ "library at that location. Load error: [%s]" ,
826
+ crypt -> opts .crypt_shared_lib_override_path .data ,
827
+ mongocrypt_status_message (crypt -> status , NULL /* len */ ));
823
828
return false;
824
829
}
825
830
0 commit comments