cat.error("No RootCA certificate found!");
log.error("No RootCA certificate found!");
    public static Certificate[] getCertChain(KeyStore keyStore, String privateKeyAlias) throws KeyStoreException {        cat.debug(">getCertChain: alias='"+privateKeyAlias+"'");        Certificate[] certchain = keyStore.getCertificateChain(privateKeyAlias);        cat.debug("Certchain retrieved from alias '"+privateKeyAlias+"' has length "+certchain.length);        if (certchain.length < 1) {            cat.error("Cannot load certificate chain with alias '"+privateKeyAlias+"' from keystore.");            cat.debug("<getCertChain: alias='"+privateKeyAlias+"', retlength="+certchain.length);            return certchain;        } else if (certchain.length > 0) {            if (CertTools.isSelfSigned((X509Certificate)certchain[certchain.length-1])) {                cat.debug("Issuer='"+((X509Certificate)certchain[certchain.length-1]).getIssuerDN()+"'.");                cat.debug("Subject='"+((X509Certificate)certchain[certchain.length-1]).getSubjectDN()+"'.");                cat.debug("<getCertChain: alias='"+privateKeyAlias+"', retlength="+certchain.length);                return certchain;            }        }        // If we came here, we have a cert which is not root cert in 'cert'        ArrayList array = new ArrayList();        for (int i=0;i<certchain.length;i++) {            array.add(certchain[i]);        }        boolean stop = false;        while (!stop) {            X509Certificate cert = (X509Certificate)array.get(array.size()-1);            String ialias = CertTools.getPartFromDN(cert.getIssuerDN().toString(), "CN");            Certificate[] chain1 = keyStore.getCertificateChain(ialias);            if (chain1 == null) {                stop = true;            } else {                cat.debug("Loaded certificate chain with length "+ chain1.length+" with alias '"+ialias+"'.");                if (chain1.length == 0) {                    cat.error("No RootCA certificate found!");                    stop = true;                }                for (int j=0;j<chain1.length;j++) {                    array.add(chain1[j]);                    // If one cert is slefsigned, we have found a root certificate, we don't need to go on anymore                    if (CertTools.isSelfSigned((X509Certificate)chain1[j]))                        stop = true;                }            }        }        Certificate[] ret = new Certificate[array.size()];        for (int i=0;i<ret.length;i++) {            ret[i] = (X509Certificate)array.get(i);            cat.debug("Issuer='"+((X509Certificate)ret[i]).getIssuerDN()+"'.");            cat.debug("Subject='"+((X509Certificate)ret[i]).getSubjectDN()+"'.");        }        cat.debug("<getCertChain: alias='"+privateKeyAlias+"', retlength="+ret.length);        return ret;    } // getCertChain