Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Throw exception when pkcs11 lib is not found #42

Closed
ricklambrechts opened this issue Dec 6, 2024 · 0 comments · Fixed by #58
Closed

Throw exception when pkcs11 lib is not found #42

ricklambrechts opened this issue Dec 6, 2024 · 0 comments · Fixed by #58
Assignees

Comments

@ricklambrechts
Copy link
Member

ricklambrechts commented Dec 6, 2024

Currently the application goes further after PKCS11LibFinder().find() and there is no lib found.

If there is no pcks11 lib found it will error, but it would be better to throw an exception beforehand.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "nl-uzipoc-yubisign\app\wizard.py", line 72, in <module>
    mainWindow = MainWindow(pkcscls, acme, oidc_provider_url)
  File "nl-uzipoc-yubisign\app\wizard.py", line 42, in __init__
    self.wizard.addPage(SelectYubiKeyPage(mypkcs))
                        ~~~~~~~~~~~~~~~~~^^^^^^^^
  File "nl-uzipoc-yubisign\app\page\selectkey.py", line 48, in __init__
    yubikeys = self._get_yubikeys()
  File "nl-uzipoc-yubisign\app\page\selectkey.py", line 20, in _get_yubikeys
    for slot in self.pkcs.pkcs11.getSlotList():
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'getSlotList'

So it would be nice if we throw an exception here.

# This will search default locations and fall back to the PYKCS11LIB environment variable
pkcslib = PKCS11LibFinder().find()
pkcscls = pkcs(pykcs11lib=pkcslib, yubikey_pin=yubikey_pin)

FYI, the default location for Windows with Yubico PIV tool is: _WINDOWS_DEFAULT_LOCATION = pathlib.Path("C:\\Program Files\\Yubico\\Yubico PIV Tool\\bin\\libykcs11.dll")

@basvandriel basvandriel self-assigned this Dec 18, 2024
@basvandriel basvandriel linked a pull request Dec 18, 2024 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants