postgresql-embedded
postgresql-embedded copied to clipboard
Enable SSL
trafficstars
Is there a recommended way to enable SSL when starting Postgres ?
this is the option "-l"
is there a way to pass it when the postgres arguments are built ?
I was able to make it work using this work-around
IRuntimeConfig sslConfig = new IRuntimeConfig() {
@Override
public ProcessOutput getProcessOutput() {
return config.getProcessOutput();
}
@Override
public ICommandLinePostProcessor getCommandLinePostProcessor() {
ICommandLinePostProcessor commandLinePostProcessor = config.getCommandLinePostProcessor();
return (distribution, args) -> {
List<String> result = commandLinePostProcessor.process(distribution, args);
if (result.get(0).endsWith("postgres")) {
result = new ArrayList<>(result);
result.add("--ssl=on");
result.add("--ssl_cert_file=" + sslCrt.getAbsolutePath());
result.add("--ssl_key_file=" + sslKey.getAbsolutePath());
}
return result;
};
}
@Override
public IArtifactStore getArtifactStore() {
return config.getArtifactStore();
}
@Override
public boolean isDaemonProcess() {
return config.isDaemonProcess();
}
};
PgTestBase.postgres.start(sslConfig,
"localhost",
8081,
"postgres",
"postgres",
"postgres",
Collections.emptyList());
perhaps we could have something built-in ?
@vietj thanks for sharing. Yes I think it could be easily built-in into the library. Would you mind to send a PR for this?
@smecsia will try to do it so, I haven't noticed your comment until today
Interested in this, did this get a PR?