public void writeCertificateTo(OutputStream stream) throws IOException, CertificateEncodingException {
        String data = "-----BEGIN CERTIFICATE-----\n" +
            Base64.getMimeEncoder(64, "\n".getBytes()).encodeToString(certificate.getEncoded()) + "\n" +
            "-----END CERTIFICATE-----";

        stream.write(data.getBytes());
        stream.flush();
    }
Utility to generate server certificate - based on Eclipse Milo stuff.
plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/KeystoreGenerator.java