Search code examples
linuxpkcs#11pkcs11interop

PkcsInterop throws Dll not found on Linux


I am getting familiar with PKCS11 and using PKCSInterop. For now, I only want to check the tokens I created on my OS (arch linux) with softhsm2-util.

I installed PKCS11Interop through Nuget, which I installed previously on archlinux.

I get this error:

Excepción no controlada del tipo 'System.DllNotFoundException' en Pkcs11Interop.dll: 'Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable

And I actually have libdl installed here

$: whereis libdl.so.2                                                                 
libdl.so.2: /usr/lib/libdl.so.2    

What should I do here?


Solution

  • You need to map libdl to libdl.so.2 in your application by using DllImportResolver delegate with NativeLibrary.SetDllImportResolver method. Sample can be seen in Pkcs11LoggerTests project. Detailed explanation can be found on github.