@@ -397,10 +397,10 @@ static _loaded_csfle _try_load_csfle(const char *filepath, mongocrypt_status_t *
397
397
// Error opening candidate
398
398
_mongocrypt_log (log ,
399
399
MONGOCRYPT_LOG_LEVEL_WARNING ,
400
- "Error while opening candidate for CSFLE dynamic library [%s]: %s" ,
400
+ "Error while opening candidate for crypt_shared dynamic library [%s]: %s" ,
401
401
filepath ,
402
402
lib .error_string .raw .data );
403
- CLIENT_ERR ("Error while opening candidate for CSFLE dynamic library [%s]: %s" ,
403
+ CLIENT_ERR ("Error while opening candidate for crypt_shared dynamic library [%s]: %s" ,
404
404
filepath ,
405
405
lib .error_string .raw .data );
406
406
// Free resources, which will include the error string
@@ -410,7 +410,7 @@ static _loaded_csfle _try_load_csfle(const char *filepath, mongocrypt_status_t *
410
410
}
411
411
412
412
// Successfully opened DLL
413
- _mongocrypt_log (log , MONGOCRYPT_LOG_LEVEL_TRACE , "Loading CSFLE dynamic library [%s]" , filepath );
413
+ _mongocrypt_log (log , MONGOCRYPT_LOG_LEVEL_TRACE , "Loading crypt_shared dynamic library [%s]" , filepath );
414
414
415
415
// Construct the library vtable
416
416
_mongo_crypt_v1_vtable vtable = {.okay = true};
@@ -425,7 +425,7 @@ static _loaded_csfle _try_load_csfle(const char *filepath, mongocrypt_status_t *
425
425
/* The requested symbol is not present */ \
426
426
_mongocrypt_log (log , \
427
427
MONGOCRYPT_LOG_LEVEL_ERROR , \
428
- "Missing required symbol '%s' from CSFLE dynamic library [%s]" , \
428
+ "Missing required symbol '%s' from crypt_shared dynamic library [%s]" , \
429
429
symname , \
430
430
filepath ); \
431
431
/* Mark the vtable as broken, but keep trying to load more symbols to \
@@ -437,17 +437,27 @@ static _loaded_csfle _try_load_csfle(const char *filepath, mongocrypt_status_t *
437
437
#undef X_FUNC
438
438
439
439
if (!vtable .okay ) {
440
+ // A common mistake is to pass the path to libmongocrypt instead of than crypt_shared.
441
+ // Check if the library has a libmongocrypt symbol.
442
+ if (mcr_dll_sym (lib , "mongocrypt_version" )) {
443
+ CLIENT_ERR ("Tried to load crypt_shared dynamic library at path [%s] but detected libmongocrypt" , filepath );
444
+ mcr_dll_close (lib );
445
+ return (_loaded_csfle ){.okay = false};
446
+ }
440
447
mcr_dll_close (lib );
441
448
_mongocrypt_log (log ,
442
449
MONGOCRYPT_LOG_LEVEL_ERROR ,
443
- "One or more required symbols are missing from CSFLE dynamic library "
450
+ "One or more required symbols are missing from crypt_shared dynamic library "
444
451
"[%s], so this dynamic library will not be used." ,
445
452
filepath );
453
+ CLIENT_ERR ("One or more required symbols are missing from crypt_shared dynamic library "
454
+ "[%s], so this dynamic library will not be used." ,
455
+ filepath );
446
456
return (_loaded_csfle ){.okay = false};
447
457
}
448
458
449
459
// Success!
450
- _mongocrypt_log (log , MONGOCRYPT_LOG_LEVEL_INFO , "Opened CSFLE dynamic library [%s]" , filepath );
460
+ _mongocrypt_log (log , MONGOCRYPT_LOG_LEVEL_INFO , "Opened crypt_shared dynamic library [%s]" , filepath );
451
461
return (_loaded_csfle ){.okay = true, .lib = lib , .vtable = vtable };
452
462
}
453
463
@@ -481,7 +491,7 @@ static bool _try_replace_dollar_origin(mstr *filepath, _mongocrypt_log_t *log) {
481
491
_mongocrypt_log (log ,
482
492
MONGOCRYPT_LOG_LEVEL_WARNING ,
483
493
"Error while loading the executable module path for "
484
- "substitution of $ORIGIN in CSFLE search path [%s]: %s" ,
494
+ "substitution of $ORIGIN in crypt_shared search path [%s]: %s" ,
485
495
filepath -> raw .data ,
486
496
error .raw .data );
487
497
mstr_free (error );
@@ -597,7 +607,7 @@ static bool _validate_csfle_singleton(mongocrypt_t *crypt, _loaded_csfle found)
597
607
bool okay = true;
598
608
if (!found .okay ) {
599
609
// There is one loaded, but we failed to find that same library. Error:
600
- CLIENT_ERR ("An existing CSFLE library is loaded by the application at "
610
+ CLIENT_ERR ("An existing crypt_shared library is loaded by the application at "
601
611
"[%s], but the current call to mongocrypt_init() failed to "
602
612
"find that same library." ,
603
613
existing_path .data );
@@ -611,9 +621,9 @@ static bool _validate_csfle_singleton(mongocrypt_t *crypt, _loaded_csfle found)
611
621
if (!mstr_eq (found_path .path .view , existing_path )) {
612
622
// Our find-result should only ever find the existing same library.
613
623
// Error:
614
- CLIENT_ERR ("An existing CSFLE library is loaded by the application at [%s], "
624
+ CLIENT_ERR ("An existing crypt_shared library is loaded by the application at [%s], "
615
625
"but the current call to mongocrypt_init() attempted to load a "
616
- "second CSFLE library from [%s]. This is not allowed." ,
626
+ "second crypt_shared library from [%s]. This is not allowed." ,
617
627
existing_path .data ,
618
628
found_path .path .raw .data );
619
629
okay = false;
0 commit comments