Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Fix error handling of credential loading #234

Merged
merged 4 commits into from
Feb 8, 2021
Merged

Conversation

jpcoenen
Copy link
Member

@jpcoenen jpcoenen commented Feb 5, 2021

There were two cases where either no error or an useless error were returned in the process of loading a credential:

  • If no passphrase was provided when using the SDK, this error would get ignored altogether. This is fixed by 8a82982.
  • After this was fixed, not setting a passphrase would lead to an "invalid passphrase" error instead of a "no passphrase provided error. This is fixed by 1a490aa (passphraseReader is now nil again in all cases that no passphrase is provided)
  • If an invalid passphrase was provided through the environment, a crypto error would be returned. This is fixed by 9f74af2.

The old behaviour of ignoring the error, resulted in errors during loading a credential (for example, a wrong passphrase), from being ignored. This resulted in getting an "unauthenticated client" error.

Creating an unauthenticated client is no longer needed now that the signup process is removed from the SDK and CLI.
This is no longer necessary because the environment variable is already checked in the decryption logic. By removing the default passphraseReader, it is also easier to determine if a passphrase has been explicitly set by just checking if the passphraseReader is nil.
Without this statement, you'd get an error about the message authentication of the encrypted credential being invalid. That's not really useful.
This test created a normal client without having a credential available. By decoupling the tested functionality from NewClient, the credential loading functionality is no longer triggered and this error is avoided.
@jpcoenen jpcoenen merged commit 5cd68e5 into master Feb 8, 2021
@jpcoenen jpcoenen deleted the fix/credential-errors branch February 8, 2021 14:42
@jpcoenen jpcoenen restored the fix/credential-errors branch February 8, 2021 14:45
@SimonBarendse SimonBarendse deleted the fix/credential-errors branch February 8, 2021 14:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants