You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> > certvalidator.errors.PathValidationError - when an error occurs validating the path
> > certvalidator.errors.RevokedError - when the certificate or another certificate in its path has been revoked
> > certvalidator.errors.InvalidCertificateError - when the certificate is not valid for the usages specified
When someone tries to catch and distinguish those exceptions, its important to know that both RevokedError and InvalidCertificateError are subclass of PathValidationError. If exceptions are attempted to be caught in the order the API documentation lists them, RevokedError and InvalidCertificateError will never be caught:
try:
validation_path=validator.validate_usage(key_usage)
exceptPathValidationErrorasex:
# handle PathValidationError# This will catch RevokedError and InvalidCertificateError too!passexceptRevokedErrorasex:
# control is never passed here!passexceptInvalidCertificateErrorasex:
# control is never passed here!pass
On the other hand those exceptions can be properly handled if PathValidationError is the last to be caught:
The API documentation of
validate.validate_usage
andvalidate.validate_tls
lists the following exceptions:certvalidator/docs/api.md
Lines 91 to 94 in 5bc5c39
When someone tries to catch and distinguish those exceptions, its important to know that both
RevokedError
andInvalidCertificateError
are subclass ofPathValidationError
. If exceptions are attempted to be caught in the order the API documentation lists them,RevokedError
andInvalidCertificateError
will never be caught:On the other hand those exceptions can be properly handled if
PathValidationError
is the last to be caught:I suggest to modify the API documentation to clarify subclassing of those exceptions and list them in a more appropriate order.
The text was updated successfully, but these errors were encountered: