use of com.intel.mtwilson.util.io.pem.Pem in project OpenAttestation by OpenAttestation.
the class X509Util method decodePemCertificates.
// public static
public static List<X509Certificate> decodePemCertificates(String text) throws CertificateException {
// String[] pems = StringUtils.splitByWholeSeparator(text, END_CERTIFICATE);
// for(String pem : pems) { log.debug("PEM: {}", pem); }
// ArrayList<X509Certificate> certs = new ArrayList<X509Certificate>(pems.length);
// for(String pem : pems) {
// if( pem.trim().isEmpty() ) { continue; }
// certs.add(decodePemCertificate(pem));
// }
List<Pem> pems = PemLikeParser.parse(text);
ArrayList<X509Certificate> certs = new ArrayList<>();
for (Pem pem : pems) {
if ("CERTIFICATE".equals(pem.getBanner())) {
// log.debug("Certificate content: {}", pem.getContent());
// byte[] content = Base64.decodeBase64(pem.getContent());
certs.add(decodeDerCertificate(pem.getContent()));
}
}
return certs;
}
Aggregations