add support for certificates not in pem format

added some error catching for certain items when connection fails