public static X509Certificate readCertificate(final InputStreamSource resource) {
        try (val in = resource.getInputStream()) {
            return CertUtil.readCertificate(in);
        } catch (final Exception e) {
            throw new IllegalArgumentException("Error reading certificate " + resource, e);
        }
    }
Read certificate.

@param resource the resource to read the cert from
@return the x 509 certificate
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/crypto/CertUtils.java