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

Use custom exception type for SSL issues #25

Closed
robin-nitrokey opened this issue Sep 28, 2023 · 0 comments · Fixed by #27
Closed

Use custom exception type for SSL issues #25

robin-nitrokey opened this issue Sep 28, 2023 · 0 comments · Fixed by #27
Assignees

Comments

@robin-nitrokey
Copy link
Member

Currently, we have some awkward code in pynitrokey to dectect self-signed SSL certificates:

        try:
            yield nethsm
        except nethsm_sdk.NetHSMError as e:
            raise click.ClickException(e)
        except urllib3.exceptions.MaxRetryError as e:
            if isinstance(e.reason, urllib3.exceptions.SSLError):
                raise click.ClickException(
                    f"Could not connect to the NetHSM: {e.reason}\nIf you use a self-signed certificate, please set the --no-verify-tls option."
                )
            else:
                raise e

It would be nice if we would not have to assume that urllib3 is used and could just check some NetHSM exception types. The urllib3 exceptions could be wrapped in NetHSMError instances and set a special flag if it is an SSL error, or a new exception could be introduced for SSL errors.

@nponsard nponsard self-assigned this Sep 28, 2023
@nponsard nponsard linked a pull request Sep 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants