code: private boolean verifyIpAddress(String ipAddress, X509Certificate certificate) {
          List<String> altNames = getSubjectAltNames(certificate, ALT_IPA_NAME);
          for (int i = 0, size = altNames.size(); i < size; i++) {
              if (ipAddress.equalsIgnoreCase(altNames.get(i))) {
                  return true;
              }
          }
  
          X500Principal principal = certificate.getSubjectX500Principal();
          // RFC 2818 advises using the most specific name for matching.
          String cn = new DistinguishedNameParser(principal).findMostSpecific("cn");
  
          // NOTE: In case of empty Common Name (CN), not checking
          return (cn == null) || ipAddress.equalsIgnoreCase(cn);
      }
docs: Returns true if {@code certificate} matches {@code ipAddress}.