code: @VisibleForTesting
    static String canonicalizeHost(String host) {
      if (host.startsWith("[") && host.endsWith("]")) {
        return host.substring(1, host.length() - 1);
      }
      return host;
    }
docs: Converts a host from URI to X509 format.
  
  <p>IPv6 host addresses derived from URIs are enclosed in square brackets per RFC2732, but
  omit these brackets in X509 certificate subjectAltName extensions per RFC5280.
  
  @see <a href="https://www.ietf.org/rfc/rfc2732.txt">RFC2732</a>
  @see <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.6">RFC5280</a>
  
  @return {@param host} in a form consistent with X509 certificates