check if key exists before reading it

@DeepDiver1975 This should at least fix the warnings we get in the latest tests regarding encryption.