Properly handle SSL connections