rewritten connection setup
SSL working