Ensure hostnames are valid DNS-or-IP names before cert validation

The existing logic relies on the caller to ensure that the hostname
supplied to the certificate verification routines is a valid domain
name or IP address. This changes that from being a caller-expected
contract to being an API guaranteed contract, by fast-failing any
hosts that aren't in one of those two forms.

Bug: 935085
Change-Id: I1ea1f02e5cb7b2bb2b07cd936cf5eac349437f74
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1686731
Commit-Queue: Ryan Sleevi <rsleevi@chromium.org>
Reviewed-by: David Benjamin <davidben@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675277}
2 files changed