Skip to content

feat: add support for additional postgres configuration fields#1898

Merged
mjuchli-da merged 7 commits into
mainfrom
da-tanabe/allow-more-postgres-config
May 28, 2026
Merged

feat: add support for additional postgres configuration fields#1898
mjuchli-da merged 7 commits into
mainfrom
da-tanabe/allow-more-postgres-config

Conversation

@da-tanabe
Copy link
Copy Markdown
Contributor

Expose the ability to use more fields than just those that are part of the schema. The main motivation for this is to enable SSL-based fields, but there may be other fields from the underlying postgres connection that people may also want to set.

I kept the original schema definitions in place so that we at least get validation for known fields; things like ports still need to be numbers, for example.

Signed-off-by: Davin K. Tanabe davin.tanabe@digitalasset.com

Signed-off-by: Davin K. Tanabe <davin.tanabe@digitalasset.com>
@da-tanabe da-tanabe force-pushed the da-tanabe/allow-more-postgres-config branch from 7e850d5 to e415b5d Compare May 27, 2026 18:47
@da-tanabe da-tanabe changed the title add support for additional postgres configuration fields feat: add support for additional postgres configuration fields May 27, 2026
Signed-off-by: rukmini-basu-da <rukmini.basu@digitalasset.com>
alexmatson-da
alexmatson-da previously approved these changes May 27, 2026
Signed-off-by: rukmini-basu-da <rukmini.basu@digitalasset.com>
Signed-off-by: Marc Juchli <marc.juchli@digitalasset.com>
Signed-off-by: Marc Juchli <marc.juchli@digitalasset.com>
@mjuchli-da mjuchli-da marked this pull request as ready for review May 28, 2026 09:45
@mjuchli-da mjuchli-da requested a review from a team as a code owner May 28, 2026 09:45
@mjuchli-da
Copy link
Copy Markdown
Contributor

Tutorial: Wallet Gateway + Postgres over TLS (Docker)

0) Prereqs

  • docker running
  • openssl available

1) Create TLS files for Postgres (self-signed)

mkdir -p .dev/postgres-tls
cd .dev/postgres-tls

# server key + cert (CN=localhost)
openssl req -x509 -newkey rsa:2048 -nodes \
  -keyout server.key -out server.crt -days 365 \
  -subj "/CN=localhost"

# Postgres requires strict key perms
chmod 600 server.key

# pg_hba: allow local socket (for init), enforce TLS for TCP
cat > pg_hba.conf <<'EOF'

# TYPE  DATABASE  USER  ADDRESS       METHOD
local   all       all                 scram-sha-256
hostssl all       all   0.0.0.0/0     scram-sha-256
hostssl all       all   ::/0          scram-sha-256
EOF

cd ../..

2) Run Postgres with TLS enabled (Docker command)

docker rm -f local-postgres 2>/dev/null || true
docker run --name local-postgres \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=app_db \
  -e POSTGRES_INITDB_ARGS="--auth-host=scram-sha-256 --auth-local=scram-sha-256" \
  -p 5432:5432 \
  -v "$PWD/.dev/postgres-tls/server.crt:/var/lib/postgresql/server.crt:ro" \
  -v "$PWD/.dev/postgres-tls/server.key:/var/lib/postgresql/server.key:ro" \
  -v "$PWD/.dev/postgres-tls/pg_hba.conf:/var/lib/postgresql/pg_hba.conf:ro" \
  -d postgres:16 \
  -c ssl=on \
  -c ssl_cert_file=/var/lib/postgresql/server.crt \
  -c ssl_key_file=/var/lib/postgresql/server.key \
  -c hba_file=/var/lib/postgresql/pg_hba.conf

3) Verify TLS works

Verify via TCP + TLS (inside container)

docker exec -e PGPASSWORD=postgres local-postgres \
  psql "host=127.0.0.1 port=5432 user=postgres dbname=app_db sslmode=require" \
  -c "select current_setting('ssl') as ssl_on;"

Expected: ssl_on = on.

4) Configure Wallet Gateway store + signingStore to use TLS

In your wallet-gateway config file, set both connections like this (quick local mode, no cert verification):

{
  "store": {
    "connection": {
      "type": "postgres",
      "host": "localhost",
      "port": 5432,
      "user": "postgres",
      "password": "postgres",
      "database": "app_db",
      "ssl": { "rejectUnauthorized": false }
    }
  },
  "signingStore": {
    "connection": {
      "type": "postgres",
      "host": "localhost",
      "port": 5432,
      "user": "postgres",
      "password": "postgres",
      "database": "app_signing_db",
      "ssl": { "rejectUnauthorized": false }
    }
  }
}

Optional: verify the server cert locally (with ssl.ca)

If you generated a CA (the “verified” variant), copy the CA PEM into a JSON string (no literal newlines):

perl -0777 -pe 's/\n/\\n/g' .dev/postgres-tls/server.crt | pbcopy

Then:

"ssl": {
  "rejectUnauthorized": true,
  "ca": "<PASTE HERE>"
}

@mjuchli-da mjuchli-da enabled auto-merge (squash) May 28, 2026 09:55
@mjuchli-da mjuchli-da self-assigned this May 28, 2026
@mjuchli-da mjuchli-da merged commit b2be8e7 into main May 28, 2026
27 checks passed
@mjuchli-da mjuchli-da deleted the da-tanabe/allow-more-postgres-config branch May 28, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants