Changelog:
- move up key file protection in order to avoid the small window between creating the file and chmoding it when it has insecure permissions