Skip to content

Commit 3ea646f

Browse files
committed
fix(espsecure): Add support for python-pkcs11 9.0+
1 parent d8ae230 commit 3ea646f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

espsecure/esp_hsm_sign/exceptions.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from esptool.logger import log
66

77
from pkcs11.exceptions import (
8-
AlreadyInitialized,
98
AnotherUserAlreadyLoggedIn,
109
ArgumentsBad,
1110
DeviceRemoved,
@@ -19,6 +18,14 @@
1918
)
2019

2120

21+
try:
22+
# AlreadyInitialized is not available since python-pkcs11 9.0, as multiple
23+
# initializations are now supported.
24+
from pkcs11.exceptions import AlreadyInitialized
25+
except ImportError:
26+
AlreadyInitialized = None
27+
28+
2229
def handle_exceptions(e, info=""):
2330
exception_type = e.__class__
2431
if exception_type == MechanismInvalid:

0 commit comments

Comments
 (0)