Reworks SSL pinning.
Adds tests for self signed certificates.
Merge pull request #1906 from OliverLetterer/new-ssl-pinning

New SSL pinning.