Add config for automatic key retrieval
(cherry picked from commit eb2e8441702abeb94a76ba421b186b2b24895e5a)