Open kloczek opened 1 year ago
PKCS11_MODULE
should point to the .so
file needed to access the HSM e.g. /usr/lib/softhsm/libsofthsm2.so
For reference you can find how check()
is done on Alpine here:
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/py3-pkcs11/APKBUILD#L41
PKCS11_MODULE
should point to the.so
file needed to access the HSM e.g./usr/lib/softhsm/libsofthsm2.so
For reference you can find how
check()
is done on Alpine here: https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/py3-pkcs11/APKBUILD#L41
Off-topic to this current issue, but... I started packaging this module for Debian, and basically started rediscovering and patching the same issues you did, until I saw your comment here! Thank you for your work! I noticed PRs for a few of these (#142, #143) but not all.
@danni Given that now we have some of these are basically just failures with a newer libraries, tools etc., perhaps you could issue a 0.7.1 fixing all these issues?
OK .. after add al necessary variables, add softhsm and asn1crypto
modile to build env I was able to start pytest.
Just after that I've hit the issu that pytest units where not able to find _pkcs11
module.
Usually something like that is caused by use relative imports which is usually nothing more than just asking for troubles beause it forces exact location of the DSO during testting using "test as installed" methodology.
Yep .. relative imports are used on massive sacale 🤔
[tkloczko@pers-jacek python-pkcs11-0.7.0]$ grep -r import | grep " \."
pkcs11/__init__.py:from .constants import * # noqa: F403
pkcs11/__init__.py:from .exceptions import * # noqa: F403
pkcs11/__init__.py:from .mechanisms import * # noqa: F403
pkcs11/__init__.py:from .types import * # noqa: F403
pkcs11/__init__.py: from . import _pkcs11
pkcs11/_errors.pyx:from .exceptions import *
pkcs11/_pkcs11.pyx: from . cimport _mswin as mswin
pkcs11/_pkcs11.pyx:from ._pkcs11_defn cimport *
pkcs11/_pkcs11.pyx:from . import types
pkcs11/_pkcs11.pyx:from .defaults import *
pkcs11/_pkcs11.pyx:from .exceptions import *
pkcs11/_pkcs11.pyx:from .constants import *
pkcs11/_pkcs11.pyx:from .mechanisms import *
pkcs11/_pkcs11.pyx:from .types import (
pkcs11/_utils.pyx:from .constants import *
pkcs11/_utils.pyx:from .mechanisms import *
pkcs11/defaults.py:from .constants import (
pkcs11/defaults.py:from .mechanisms import Mechanism, KeyType, MGF
pkcs11/types.py:from .constants import (
pkcs11/types.py:from .mechanisms import KeyType, Mechanism
pkcs11/types.py:from .exceptions import (
pkcs11/util/dh.py:from . import biginteger
pkcs11/util/dh.py:from ..constants import Attribute
pkcs11/util/dh.py:from ..exceptions import AttributeTypeInvalid
pkcs11/util/dsa.py:from . import biginteger
pkcs11/util/dsa.py:from ..constants import Attribute
pkcs11/util/ec.py:from ..constants import Attribute, ObjectClass
pkcs11/util/ec.py:from ..mechanisms import KeyType
pkcs11/util/rsa.py:from . import biginteger
pkcs11/util/rsa.py:from ..constants import Attribute, ObjectClass, MechanismFlag
pkcs11/util/rsa.py:from ..mechanisms import KeyType
pkcs11/util/rsa.py:from ..defaults import DEFAULT_KEY_CAPABILITIES
pkcs11/util/x509.py:from ..constants import Attribute, ObjectClass, CertificateType
pkcs11/util/x509.py:from ..mechanisms import KeyType
pkcs11/util/x509.py: from .rsa import decode_rsa_public_key
pkcs11/util/x509.py: from .dsa import decode_dsa_domain_parameters, decode_dsa_public_key
pkcs11/_pkcs11.c: * from .exceptions import * # <<<<<<<<<<<<<<
pkcs11/_pkcs11.c: * from .constants import * # <<<<<<<<<<<<<<
pkcs11/_pkcs11.c: * from .mechanisms import *
pkcs11/_pkcs11.c: * from .constants import *
pkcs11/_pkcs11.c: * from .mechanisms import * # <<<<<<<<<<<<<<
pkcs11/_pkcs11.c: * from . import types # <<<<<<<<<<<<<<
pkcs11/_pkcs11.c: * from .defaults import *
pkcs11/_pkcs11.c: * from .exceptions import *
pkcs11/_pkcs11.c: * from . import types
pkcs11/_pkcs11.c: * from .defaults import * # <<<<<<<<<<<<<<
pkcs11/_pkcs11.c: * from .exceptions import *
pkcs11/_pkcs11.c: * from .constants import *
pkcs11/_pkcs11.c: * from . import types
pkcs11/_pkcs11.c: * from .defaults import *
pkcs11/_pkcs11.c: * from .exceptions import * # <<<<<<<<<<<<<<
pkcs11/_pkcs11.c: * from .constants import *
pkcs11/_pkcs11.c: * from .mechanisms import *
pkcs11/_pkcs11.c: * from .defaults import *
pkcs11/_pkcs11.c: * from .exceptions import *
grep: pkcs11/_pkcs11.c: * from .constants import * # <<<<<<<<<<<<<<
pkcs11/__pycache__/types.cpython-38.pyc: binary file matchespkcs11/_pkcs11.c: * from .mechanisms import *
pkcs11/_pkcs11.c: * from .types import (
pkcs11/_pkcs11.c: * from .exceptions import *
pkcs11/_pkcs11.c: * from .constants import *
pkcs11/_pkcs11.c: * from .mechanisms import * # <<<<<<<<<<<<<<
pkcs11/_pkcs11.c: * from .types import (
pkcs11/_pkcs11.c: * from .mechanisms import *
pkcs11/_pkcs11.c: * from .types import (
pkcs11/_pkcs11.c: * from .constants import *
pkcs11/_pkcs11.c: * from .mechanisms import *
pkcs11/_pkcs11.c: * from .types import ( # <<<<<<<<<<<<<<
tests/test_aes.py:from . import TestCase, requires, FIXME
tests/test_des.py:from . import TestCase, requires
tests/test_dh.py:from . import TestCase, requires, FIXME
tests/test_digest.py:from . import TestCase, Not, requires
tests/test_dsa.py:from . import TestCase, requires, FIXME
tests/test_ecc.py:from . import TestCase, requires
tests/test_iterators.py:from . import TestCase, requires
tests/test_public_key_external.py:from . import TestCase, requires, Is
tests/test_rsa.py:from . import TestCase, requires, FIXME
tests/test_sessions.py:from . import TestCase, TOKEN_PIN, TOKEN_SO_PIN, Not, Only, requires, FIXME
tests/test_slots_and_tokens.py:from . import LIB, TOKEN, Only, Not
tests/test_threading.py:from . import TestCase, Not, requires
tests/test_x509.py:from . import TestCase, Not, Only, requires, OPENSSL
Sometimes is relative imports are not overused it is possible to start tests with --import-mode=importlib
but in this case it did not help and with that pytest is not able o tests
.
Gentle ping .. any update? 🤔
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulescut off from access to the public network
(pytest is executed with-m "not network"
)Here is pytest output:
Q: what needs to be passed in $PKCS11_MODULE? 🤔