add support for certificates not in pem format

added some error catching for certain items when connection fails
fixed handling of non pem certs
fixed wrong error message when auth is invalid or missing