Skip to content

Commit

Permalink
Handle malformed inputs given via the CLI more gracefully
Browse files Browse the repository at this point in the history
Instead of crashing and exposing the traceback of pyasn1
internals, show an error message. This can help differentiate
an error inside pkilint from an error inside the input data.
  • Loading branch information
ralienpp committed Mar 22, 2024
1 parent b55c6a9 commit f274cdc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkilint/bin/lint_pkix_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def main(cli_args=None) -> int:

return 0
else:
cert = loader.load_certificate(args.file, args.file.name)
try:
cert = loader.load_certificate(args.file, args.file.name)
except ValueError as e:
print(f'Failed to load certificate: {e}')
return 1

results = doc_validator.validate(cert.root)

Expand Down

0 comments on commit f274cdc

Please sign in to comment.