You should also check if your .pem file is not corrupted. I spent about an hour scratching my head and decided to check using this line
openssl rsa -check -in test.pem -noout
If it returns "RSA key ok" then you are good. If not, make sure you have the right file and or copied it correctly for whatever reason.