Skip to content

Commit 45c8559

Browse files
authored
Merge branch 'main' into feature/share_statement_cache_with_diesel
2 parents 4d349df + 7e0267b commit 45c8559

File tree

4 files changed

+11
-25
lines changed

4 files changed

+11
-25
lines changed

examples/postgres/pooled-with-rustls/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ edition = "2021"
99
diesel-async = { version = "0.5.0", path = "../../../", features = ["bb8", "postgres"] }
1010
futures-util = "0.3.21"
1111
rustls = "0.23.8"
12-
rustls-native-certs = "0.7.1"
12+
rustls-platform-verifier = "0.5.0"
1313
tokio = { version = "1.2.0", default-features = false, features = ["macros", "rt-multi-thread"] }
1414
tokio-postgres = "0.7.7"
15-
tokio-postgres-rustls = "0.12.0"
15+
tokio-postgres-rustls = "0.13.0"
1616

1717

1818
[dependencies.diesel]

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

+3-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use diesel_async::pooled_connection::ManagerConfig;
55
use diesel_async::AsyncPgConnection;
66
use futures_util::future::BoxFuture;
77
use futures_util::FutureExt;
8+
use rustls::ClientConfig;
9+
use rustls_platform_verifier::ConfigVerifierExt;
810
use std::time::Duration;
911

1012
#[tokio::main]
@@ -42,9 +44,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4244
fn establish_connection(config: &str) -> BoxFuture<ConnectionResult<AsyncPgConnection>> {
4345
let fut = async {
4446
// We first set up the way we want rustls to work.
45-
let rustls_config = rustls::ClientConfig::builder()
46-
.with_root_certificates(root_certs())
47-
.with_no_client_auth();
47+
let rustls_config = ClientConfig::with_platform_verifier();
4848
let tls = tokio_postgres_rustls::MakeRustlsConnect::new(rustls_config);
4949
let (client, conn) = tokio_postgres::connect(config, tls)
5050
.await
@@ -54,10 +54,3 @@ fn establish_connection(config: &str) -> BoxFuture<ConnectionResult<AsyncPgConne
5454
};
5555
fut.boxed()
5656
}
57-
58-
fn root_certs() -> rustls::RootCertStore {
59-
let mut roots = rustls::RootCertStore::empty();
60-
let certs = rustls_native_certs::load_native_certs().expect("Certs not loadable!");
61-
roots.add_parsable_certificates(certs);
62-
roots
63-
}

examples/postgres/run-pending-migrations-with-rustls/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ edition = "2021"
88
[dependencies]
99
diesel-async = { version = "0.5.0", path = "../../../", features = ["bb8", "postgres", "async-connection-wrapper"] }
1010
futures-util = "0.3.21"
11-
rustls = "0.23.10"
12-
rustls-native-certs = "0.7.1"
11+
rustls = "0.23.8"
12+
rustls-platform-verifier = "0.5.0"
1313
tokio = { version = "1.2.0", default-features = false, features = ["macros", "rt-multi-thread"] }
1414
tokio-postgres = "0.7.7"
15-
tokio-postgres-rustls = "0.12.0"
15+
tokio-postgres-rustls = "0.13.0"
1616

1717
[dependencies.diesel]
1818
version = "2.2.0"

examples/postgres/run-pending-migrations-with-rustls/src/main.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use diesel_async::AsyncPgConnection;
44
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
55
use futures_util::future::BoxFuture;
66
use futures_util::FutureExt;
7+
use rustls::ClientConfig;
8+
use rustls_platform_verifier::ConfigVerifierExt;
79

810
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
911

@@ -28,9 +30,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2830
fn establish_connection(config: &str) -> BoxFuture<ConnectionResult<AsyncPgConnection>> {
2931
let fut = async {
3032
// We first set up the way we want rustls to work.
31-
let rustls_config = rustls::ClientConfig::builder()
32-
.with_root_certificates(root_certs())
33-
.with_no_client_auth();
33+
let rustls_config = ClientConfig::with_platform_verifier();
3434
let tls = tokio_postgres_rustls::MakeRustlsConnect::new(rustls_config);
3535
let (client, conn) = tokio_postgres::connect(config, tls)
3636
.await
@@ -39,10 +39,3 @@ fn establish_connection(config: &str) -> BoxFuture<ConnectionResult<AsyncPgConne
3939
};
4040
fut.boxed()
4141
}
42-
43-
fn root_certs() -> rustls::RootCertStore {
44-
let mut roots = rustls::RootCertStore::empty();
45-
let certs = rustls_native_certs::load_native_certs().expect("Certs not loadable!");
46-
roots.add_parsable_certificates(certs);
47-
roots
48-
}

0 commit comments

Comments
 (0)