private KeyStore generate(String password, int length, String applicationUri, String entryName, String commonName) throws Exception {
        KeyStore keyStore = KeyStore.getInstance("PKCS12");
        keyStore.load(null, password.toCharArray());
        KeyPair keyPair = SelfSignedCertificateGenerator.generateRsaKeyPair(length);
        SelfSignedCertificateBuilder builder = (new SelfSignedCertificateBuilder(
            keyPair)).setCommonName(commonName)
            .setOrganization("Apache Software Foundation")
            .setOrganizationalUnit("PLC4X")
            .setLocalityName("PLC4J")
            .setStateName("CA")
            .setCountryCode("US")
            .setApplicationUri(applicationUri);

        Set<String> hostnames = Set.of("127.0.0.1");

        for (String hostname : hostnames) {
            if (hostname.startsWith("\\d+\\.")) {
                builder.addIpAddress(hostname);
            } else {
                builder.addDnsName(hostname);
            }
        }

        X509Certificate certificate = builder.build();
        keyStore.setKeyEntry(entryName, keyPair.getPrivate(), password.toCharArray(), new X509Certificate[]{ certificate });
        return keyStore;
    }
Utility to generate server certificate - based on Eclipse Milo stuff.
plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/KeystoreGenerator.java