code: private Collection<String> getCertServerNames(X509Certificate x509)
          throws CertificateParsingException {
  
          Collection<String> serverNames = new LinkedHashSet<>();
  
          /* Add CN for the certificate */
          String certCN = getCertCN(x509);
          serverNames.add(certCN);
  
          /* Add alternative names for each certificate */
          try {
              Collection<List<?>> altNames = x509.getSubjectAlternativeNames();
              if (altNames != null) {
                  for (List<?> entry : altNames) {
                      if (entry.size() >= 2) {
                          Object entryType = entry.get(0);
                          if (entryType instanceof Integer &&
                              (Integer) entryType == 2) {
  
                              Object field = entry.get(1);
                              if (field instanceof String) {
                                  serverNames.add(((String) field).toLowerCase());
                              }
                          }
                      }
                  }
              }
  
          } catch (CertificateParsingException cpe) {
              LOGGER.warn("Certificate alternative names ignored for certificate " + (certCN != null ? " " + certCN : ""), cpe);
          }
  
          return serverNames;
      }
docs: Build up the list of server names represented by a certificate