added error handling on private key stat in case it is saved in agent

but not in filesystem, this should solve #9507