private PrivateKey readPemPrivateKey() {
        LOGGER.trace("Attempting to read as PEM [{}]", this.location);
        try (val in = new InputStreamReader(this.location.getInputStream(), StandardCharsets.UTF_8);
             val br = new BufferedReader(in);
             val pp = new PEMParser(br)) {

            val object = pp.readObject();
            if (object instanceof final PrivateKeyInfo info) {
                return new JcaPEMKeyConverter().getPrivateKey(info);
            }
            if (object instanceof final PEMKeyPair pemKeyPair) {
                val kp = new JcaPEMKeyConverter().getKeyPair(pemKeyPair);
                return kp.getPrivate();
            }
        } catch (final Exception e) {
            LOGGER.debug("Unable to read key", e);
        }
        return null;
    }
Factory Bean for creating a private key from a file.

@author Scott Battaglia
@since 3.1
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/crypto/PrivateKeyFactoryBean.java