Use library-provided hostname verification where available

GnuTLS offers some APIs for verifying host names since some time. Use
that if available.
OpenSSL .next will also offer something similar, so use that with
OpenSSL TLS when available.

I left the old code in for now, in case some folks are still using very
old versions of GnuTLS (uncommon) or non-bleeding-edge versions of
OpenSSL (very common).