fixed handling of non pem certs
fixed wrong error message when auth is invalid or missing