Search in sources :

Example 1 with Pem

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;
}
Also used : ArrayList(java.util.ArrayList) Pem(com.intel.mtwilson.util.io.pem.Pem) X509Certificate(java.security.cert.X509Certificate)

Aggregations

Pem (com.intel.mtwilson.util.io.pem.Pem)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1