In the past I was able to successfully use the python-pkcs11 package to perform cryptographic operations with a Thales netHsm. I'm using Python 3.7 and I have an environment variable called PKCS11_MODULE that points to the location of my pkcs11 library (in this case, it's cknfast-32.dll, a pkcs11 library provided by nCipher). However, now when I run:
import pkcs11
import os
lib = pkcs11.lib(os.environ['PKCS11_MODULE'])
I get the following error:
Traceback (most recent call last):
File "pkcs11\_errors.pyx", line 88, in pkcs11._pkcs11.assertRV
RuntimeError: Initialisation error (not initialized). Should never see this.
Exception ignored in: 'pkcs11._pkcs11.lib.__dealloc__'
Traceback (most recent call last):
File "pkcs11\_errors.pyx", line 88, in pkcs11._pkcs11.assertRV
RuntimeError: Initialisation error (not initialized). Should never see this.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\site-packages\python_pkcs11-0.5.1.dev35+g7f4427d-py3.7-win32.egg\pkcs11\__init__.py", line 32, in lib
_lib = _pkcs11.lib(so)
File "pkcs11\_pkcs11.pyx", line 1245, in pkcs11._pkcs11.lib.__cinit__
File "pkcs11\_errors.pyx", line 88, in pkcs11._pkcs11.assertRV
pkcs11.exceptions.FunctionFailed
It seems that python-pkcs11 is no longer able to load my pkcs11 library. Please advise if you have a solution. Thanks in advance.