Major rewrite for TLS and splitting things up

The short version of this pull request is that I've implemented the TLS stuff (including indexing clients by certificate fingerprint). The long version is ~110 lines of code and you can read it to find out more!