/** * Creates an X.509 certificate chain from its ASN.1 encoded form. * * @param encoded Sequence of PEM or DER encoded certificates or PKCS#7 certificate chain. * * @return Certificate. * * @throws EncodingException on cert parsing errors. */ public static X509Certificate[] decodeCertificateChain(final byte[] encoded) throws EncodingException { return readCertificateChain(new ByteArrayInputStream(encoded)); }
/** {@inheritDoc} */ @Override public X509Certificate[] getObject() throws Exception { if (certificates == null) { if (resource == null) { throw new BeanCreationException( "Certificate chain resource must be provided in order to use this factory."); } try (InputStream is = resource.getInputStream()) { certificates = CertUtil.readCertificateChain(is); } } return certificates; }
/** * Reads an X.509 certificate chain from ASN.1 encoded format in the file at the given location. * * @param path Path to file containing a sequence of PEM or DER encoded certificates or PKCS#7 certificate chain. * * @return Certificate. * * @throws EncodingException on cert parsing errors. * @throws StreamException on IO errors. */ public static X509Certificate[] readCertificateChain(final String path) throws EncodingException, StreamException { return readCertificateChain(StreamUtil.makeStream(new File(path))); }
/** * Reads an X.509 certificate chain from ASN.1 encoded format from the given file. * * @param file File containing a sequence of PEM or DER encoded certificates or PKCS#7 certificate chain. * * @return Certificate. * * @throws EncodingException on cert parsing errors. * @throws StreamException on IO errors. */ public static X509Certificate[] readCertificateChain(final File file) throws EncodingException, StreamException { return readCertificateChain(StreamUtil.makeStream(file)); }