added cert-based authentification and server cert validitation.
client key and cert can be generated with openssl:
openssl genrsa -out key.pem 4096
openssl req -x509 -key key.pem -out cert.pem -days 365
(maybe tweak the days value, or leave it to not lose the knowledge ;) )
the hackint ca cert can be found at https://hackint.org/crt/rootca.crt