postgresql-embedded icon indicating copy to clipboard operation
postgresql-embedded copied to clipboard

Enable SSL

Open vietj opened this issue 8 years ago • 5 comments
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 ?

vietj avatar Sep 15 '17 20:09 vietj

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());

vietj avatar Sep 15 '17 21:09 vietj

perhaps we could have something built-in ?

vietj avatar Sep 15 '17 21:09 vietj

@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 avatar Sep 18 '17 01:09 smecsia

@smecsia will try to do it so, I haven't noticed your comment until today

vietj avatar Dec 07 '17 17:12 vietj

Interested in this, did this get a PR?

mcassano avatar Feb 19 '19 20:02 mcassano