Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined symbol: C_Initialize #2

Closed
vanhonit opened this issue May 9, 2013 · 5 comments
Closed

undefined symbol: C_Initialize #2

vanhonit opened this issue May 9, 2013 · 5 comments

Comments

@vanhonit
Copy link

vanhonit commented May 9, 2013

When i run test i receive error: "Unable to get function pointer: opensc-pkcs11.so undefined symbol C_Initialize" .
I'm use Fedora 18 64bit.

@jariq
Copy link
Member

jariq commented May 9, 2013

I guess you've hit one of a few limitations of the current pkcs11interop implementation (please see section "Supported features" on www.pkcs11interop.net for more info) specifically that unmanaged libraries that export only C_GetFunctionList() function are supported only on MS Windows platform. And unfortunately opensc-pkcs11.so is one of those libraries as you can see in its source code: https://github.com/OpenSC/OpenSC/blob/master/src/pkcs11/opensc-pkcs11.exports

This limitation exists because of the marshaling problem (probably bug) in Mono. I am planning to create test case and bug report for Mono next week, but it can take long time till it gets fixed there. So meanwhile you can try to use something like "proxy PKCS#11 library" that exports all PKCS#11 functions directly and put it in front of the opensc-pkcs11.so. Please take a look at my other project pkcs11-logger that implements such library: https://github.com/jariq/pkcs11-logger

You should be able to easily create following setup which should work even on linux:

Your application <---> pkcs11interop.dll <---> pkcs11-logger.so <---> opensc-pkcs11.so

@vanhonit
Copy link
Author

vanhonit commented May 9, 2013

Thanks for feedback, I will try. But another question how to you pkcs11-logger know where opensc-pkcs11 save ?

@jariq
Copy link
Member

jariq commented May 9, 2013

By default logger tries to load PKCS#11 library provided by OpenSC project which is "opensc-pkcs11.dll" on Windows or "opensc-pkcs11.so" on Linux. But you can use PKCS11_LOGGER_ORIG_LIB environment variable to specify another library.

This is the "classic" way to use Pkcs11interop:

using (Pkcs11 pkcs11 = new Pkcs11("opensc-pkcs11.so", true))
{
// Do something interesting
}

This is how you use Pkcs11Interop with pkcs11-logger:

Environment.SetEnvironmentVariable("PKCS11_LOGGER_ORIG_LIB", "opensc-pkcs11.so");
using (Pkcs11 pkcs11 = new Pkcs11("pkcs11-logger.so", true))
{
// Do something interesting
}

@vanhonit
Copy link
Author

Thanks, jariq !

@jariq
Copy link
Member

jariq commented May 25, 2013

I've found a workaround for this issue and the fix was committed to the master git repository few minutes ago. From now on you don't have to use pkcs11-logger as a proxy library. Latest development version can be downloaded from https://github.com/jariq/Pkcs11Interop/archive/master.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants