core: let nm_utils_secret_key_read() handle failures internally
and add nm_utils_secret_key_get() to cache the secret-key, to only obtain it once. nm_utils_secret_key_read() is not expected to fail. However, in case of an unexpected error, don't propagate the error to the caller, but instead handle it internally. That means, in case of error: - log a warning within nm_utils_secret_key_read() itself. - always return a generated secret-key. In case of error, the key won't be persisted (obviously). But the caller can ignore the error and just proceed with an in-memory key. Hence, also add nm_utils_secret_key_get() to cache the key. This way, we only try to actually generate/read the secret-key once. Since that might fail and return an in-memory key, we must for future invocations return the same key, without generating a new one.
Showing with 93 additions and 50 deletions