/** * Reads an X.509 certificate from ASN.1 encoded format from the given file. * * @param file File containing an DER or PEM encoded X.509 certificate. * * @return Certificate. * * @throws EncodingException on cert parsing errors. * @throws StreamException on IO errors. */ public static X509Certificate readCertificate(final File file) throws EncodingException, StreamException { return readCertificate(StreamUtil.makeStream(file)); }
/** * 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 from ASN.1 encoded format in the file at the given location. * * @param path Path to file containing an DER or PEM encoded X.509 certificate. * * @return Certificate. * * @throws EncodingException on cert parsing errors. * @throws StreamException on IO errors. */ public static X509Certificate readCertificate(final String path) throws EncodingException, StreamException { return readCertificate(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)); }
/** * Reads all the data from the given file. * * @param file File to read. * * @return Byte array of data read from file. * * @throws StreamException on stream IO errors. */ public static byte[] readAll(final File file) throws StreamException { final InputStream input = makeStream(file); try { return readAll(input, (int) file.length()); } finally { closeStream(input); } }