private void writeEncodedCertificateToFile(final File file, final byte[] certificate) {
        if (file.exists()) {
            val res = file.delete();
            logger.debug("Deleted file [{}]:{}", file, res);
        }
        try (var pemWriter = new PemWriter(
            new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
            PemObjectGenerator pemObject = new PemObject(file.getName(), certificate);
            pemWriter.writeObject(pemObject);
        } catch (final Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
<p>Constructor for SAML2FileSystemKeystoreGenerator.</p>

@param configuration a {@link SAML2Configuration} object
pac4j-saml/src/main/java/org/pac4j/saml/metadata/keystore/SAML2FileSystemKeystoreGenerator.java