From e40774f54683ba24ffed63aa14bebc8ab42ed087 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 10 Jan 2016 23:54:25 +0100 Subject: [PATCH] Linux/MacOSX: Show better error message when the PKCS#11 library can't be loaded --- src/Common/SecurityToken.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp index d7dacf57..a3fc18d6 100644 --- a/src/Common/SecurityToken.cpp +++ b/src/Common/SecurityToken.cpp @@ -520,11 +520,13 @@ namespace VeraCrypt CloseLibrary(); #ifdef TC_WINDOWS - Pkcs11LibraryHandle = LoadLibraryW (pkcs11LibraryPath.c_str()); -#else - Pkcs11LibraryHandle = dlopen (pkcs11LibraryPath.c_str(), RTLD_NOW | RTLD_LOCAL); -#endif + Pkcs11LibraryHandle = LoadLibraryW (pkcs11LibraryPath.c_str()); throw_sys_if (!Pkcs11LibraryHandle); +#else + Pkcs11LibraryHandle = dlopen (pkcs11LibraryPath.c_str(), RTLD_NOW | RTLD_LOCAL); + throw_sys_sub_if (!Pkcs11LibraryHandle, dlerror()); +#endif + typedef CK_RV (*C_GetFunctionList_t) (CK_FUNCTION_LIST_PTR_PTR ppFunctionList); #ifdef TC_WINDOWS