Fix an issue where a directory in the keys dirs would cause

The master to crash, per #3946