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

signer: Handle the "yubikey auth required" case #528

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions signer/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ python_version = "3.9"
[[tool.mypy.overrides]]
module = [
"securesystemslib.*",
"PyKCS11.*",
]
ignore_missing_imports = "True"

Expand Down
10 changes: 9 additions & 1 deletion signer/tuf_on_ci_sign/_signer_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from enum import Enum, unique

import click
from PyKCS11 import CKR_USER_NOT_LOGGED_IN, PyKCS11Error
from securesystemslib.exceptions import UnverifiedSignatureError
from securesystemslib.formats import encode_canonical
from securesystemslib.hash import digest
Expand Down Expand Up @@ -289,7 +290,14 @@ def _sign(self, role: str, md: Metadata, key: Key) -> None:
self.user.set_signer(key, signer)
break
except UnsignedMetadataError as e:
print(f"Failed to sign {role} with {self.user.name} key.\n {e}")
# Very light error handling for specific PKCS11 errors
msg = str(e)
if isinstance(e.__context__, PyKCS11Error):
pkcs_err = e.__context__
if pkcs_err.value == CKR_USER_NOT_LOGGED_IN:
msg = "Required authentication (e.g. touch) did not happpen"

print(f"Failed to sign {role} with {self.user.name} key:\n {msg}")
logger.debug("Sign traceback", exc_info=True)
except UnverifiedSignatureError as e:
print(
Expand Down
Loading