Skip to content

Commit

Permalink
Fix cryptography deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Jan 23, 2024
1 parent 0ba68eb commit 23233a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ packages = [

[tool.poetry.dependencies]
python = "^3.8"
cryptography = ">=3.0, <44"
cryptography = ">=3.0, <45"
pyscard = "^2.0"
fido2 = "^1.0"
click = "^8.0"
Expand Down
10 changes: 8 additions & 2 deletions ykman/piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,18 @@ def get_piv_info(session: PivSession):
key_algo = "Unsupported"
serial = cert.serial_number
try:
not_before: Optional[datetime] = cert.not_valid_before
try: # Prefer timezone-aware variant (cryptography >= 42)
not_before: Optional[datetime] = cert.not_valid_before_utc
except AttributeError:
not_before = cert.not_valid_before
except ValueError:
logger.debug("Failed reading not_valid_before", exc_info=True)
not_before = None
try:
not_after: Optional[datetime] = cert.not_valid_after
try: # Prefer timezone-aware variant (cryptography >= 42)
not_after: Optional[datetime] = cert.not_valid_after_utc
except AttributeError:
not_after = cert.not_valid_after
except ValueError:
logger.debug("Failed reading not_valid_after", exc_info=True)
not_after = None
Expand Down

0 comments on commit 23233a6

Please sign in to comment.