code: public boolean isValidCertChain(Certificate targetCert, List<Certificate> certs) {
  
          try {
              KeyStore cacerts = this.caCertService.getCaCertKeystore();
              for (Certificate cert : certs) {
                  if (cert == targetCert) continue;
                  cacerts.setCertificateEntry(((X509Certificate) cert).getSubjectDN().toString(), cert);
              }
              return this.chainValidator.validateKeyChain((X509Certificate) targetCert, cacerts);
          } catch (Exception e) {
              e.printStackTrace();
          }
          return false;
      }
docs: Validate whether the target cert is valid using the CA Certificate KeyStore and any included intermediate certificates
  @param targetCert Target certificate to validate
  @param certs Intermediate certificates to using during validation
  @return isCertChainValid?