add bit of logging and fix SSL certificate check.