private static String toPem(byte[] binary, String label) {
        String base64 = Base64.getMimeEncoder(64, "\n".getBytes())
                              .encodeToString(binary);
        return "-----BEGIN " + label + "-----\n"
             + base64
             + "\n-----END " + label + "-----\n";
    }
Convert raw DER bytes into a PEM-format string, with BEGIN/END lines.
integration/logstash-plugins/logstash-output-vespa/src/main/java/org/logstashplugins/SelfSignedCertGenerator.java