Implemented most of the ssl server (copied from the serf project).