Fix infinity read bug
Check whether pem file exists
Graceful exception control