Skip to content

Commit 144b488

Browse files
committed
Update rustls exmaple for work with newest updates to the crate. Also README section added to point out the need for this example
1 parent 74867bd commit 144b488

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ let mut conn = pool.get().await?;
168168
let res = users::table.select(User::as_select()).load::(&mut conn).await?;
169169
```
170170

171+
## Diesel-Async with Secure Database
172+
173+
In the event of using this crate with a `sslmode=require` flag, it will be necessary to build a TLS cert.
174+
There is an example provided for doing this using the `rustls` crate in the `postgres` examples folder.
175+
171176
## Crate Feature Flags
172177

173178
Diesel-async offers several configurable features:

examples/postgres/pooled-with-rustls/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ fn establish_connection(config: &str) -> BoxFuture<ConnectionResult<AsyncPgConne
6363
fn root_certs() -> rustls::RootCertStore {
6464
let mut roots = rustls::RootCertStore::empty();
6565
let certs = rustls_native_certs::load_native_certs().expect("Certs not loadable!");
66-
let certs: Vec<_> = certs.into_iter().map(|cert| cert.0).collect();
67-
roots.add_parsable_certificates(&certs);
66+
roots.add_parsable_certificates(certs);
6867
roots
6968
}

0 commit comments

Comments
 (0)