Removed tmpDir and added ability to pass private key which does solve the security issue