@Override
    public void writeCertificateAndKey(final Writer privateKeyWriter, final Writer certificateWriter) {
        FunctionUtils.doUnchecked(__ -> {
            val keypair = generateKeyPair();
            val certificate = generateCertificate(keypair);
            try (val keyOut = new JcaPEMWriter(privateKeyWriter)) {
                keyOut.writeObject(keypair.getPrivate());
                keyOut.flush();
            }

            try (val certOut = new JcaPEMWriter(certificateWriter)) {
                certOut.writeObject(certificate);
                certOut.flush();
            }
        });
    }
This is {@link DefaultSamlIdPCertificateAndKeyWriter}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-saml-idp-core/src/main/java/org/apereo/cas/support/saml/idp/metadata/writer/DefaultSamlIdPCertificateAndKeyWriter.java