Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<Certificate> loadCertificates(String[] pemEncodedCerts) throws Exception {

        List<Certificate> certList = new ArrayList<>();
        CertificateFactory certFactory = CertificateFactory.getInstance("X.509");

        for (String certPem : pemEncodedCerts) {
            InputStream certIn = new ByteArrayInputStream(certPem.getBytes());
            Certificate cert = certFactory.generateCertificate(certIn);
            certList.add(cert);
        }

        return certList;
    }
}