Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.72 KB

File metadata and controls

58 lines (42 loc) · 1.72 KB

deadpool-postgres + ntex + rustls example

Based on deadpool-postgres example.

Adapted to Ntex and Rustls.

This example combines deadpool-postgres with a ntex webservice to implement a simple API service that responds with JSON read from PostgreSQL.

Instructions to run example, see https://github.com/bikeshedder/deadpool/blob/master/examples/postgres-actix-web/README.md#running-the-example.

Postgres

  • Create postgres deadpool db.
  • Load data fixture.sql
  • Create .env file

Run example

cargo run

Postgres config

Copy certificates to postgres directory or configure the path to them in postgres.conf.

postgresql.conf

ssl = on
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'
ssl_ca_file = 'ca.crt'

pg_hba.conf

# Only allow SSL connections
hostssl all             all             127.0.0.1/32            md5
hostssl all             all             ::1/128                 md5
hostssl all             all             0.0.0.0/0               md5

verify-full option

Verify/identify client and server

pg_hba.conf

# Only allow SSL connections
hostssl all             all             127.0.0.1/32            cert    clientcert=verify-full
hostssl all             all             ::1/128                 cert    clientcert=verify-full
hostssl all             all             0.0.0.0/0               cert    clientcert=verify-full

Connect with client psql

$ psql "host=127.0.0.1 port=5432 dbname=deadpool user=postgres sslmode=verify-full sslcert=client.crt sslkey=client.key sslrootcert=ca.crt"