protected PublicKey readPemPublicKey() throws Exception {
        try (val reader = new PemReader(new InputStreamReader(this.resource.getInputStream(), StandardCharsets.UTF_8))) {
            val pemObject = reader.readPemObject();
            if (pemObject != null) {
                val content = pemObject.getContent();
                val pubSpec = new X509EncodedKeySpec(content);
                val factory = KeyFactory.getInstance(this.algorithm);
                return factory.generatePublic(pubSpec);
            }
        }
        return null;
    }
Initialize cipher based on service public key.

@return the false if no public key is found
or if cipher cannot be initialized, etc.
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/crypto/PublicKeyFactoryBean.java