Commit 0b27115
committed
store: Fix TLS regression in diesel-async connection pool
The migration from synchronous diesel (r2d2 + PgConnection) to
diesel-async (deadpool + AsyncPgConnection) in the "Make the store
async" change inadvertently broke TLS support for the database
connection pool.
The old code used diesel::r2d2::ConnectionManager<PgConnection> which
is backed by libpq (via pq-sys). libpq defaults to sslmode=prefer,
meaning it transparently negotiates TLS with the server when available.
The new code uses diesel_async::AsyncPgConnection::establish() which
internally calls tokio_postgres::connect() with tokio_postgres::NoTls,
meaning TLS is never negotiated regardless of the sslmode parameter in
the connection URL. This breaks connections to any PostgreSQL server
that requires encrypted connections via pg_hba.conf.
Fix this by replacing AsyncPgConnection::establish() with a manual
tokio_postgres::connect() call using postgres-openssl as the TLS
connector (with SslVerifyMode::NONE to match libpq's default prefer
behavior), then constructing the AsyncPgConnection via
try_from_client_and_connection(). This restores the pre-v0.42.0
behavior where connections are encrypted by default.
Note: tokio-postgres does not support sslmode=verify-ca or
sslmode=verify-full in its URL parser — only disable, prefer, and
require are recognized. Certificate verification would require
upstream changes to tokio-postgres.
The openssl and postgres-openssl crates were already dependencies of
graph-store-postgres (used by the notification listener). Only
tokio-postgres was added as a new direct dependency.1 parent 277f45e commit 0b27115
3 files changed
Lines changed: 55 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
108 | 143 | | |
109 | 144 | | |
110 | 145 | | |
| |||
249 | 284 | | |
250 | 285 | | |
251 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
252 | 299 | | |
253 | 300 | | |
254 | 301 | | |
| |||
0 commit comments