Skip to content

Commit b638313

Browse files
authored
fix: remove pgstac custom tls stuff (#587)
- Closes #575
1 parent a9c7534 commit b638313

File tree

5 files changed

+17
-134
lines changed

5 files changed

+17
-134
lines changed

crates/pgstac/Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@ repository.workspace = true
1111
license.workspace = true
1212
rust-version.workspace = true
1313

14-
[features]
15-
tls = ["dep:rustls", "dep:tokio-postgres-rustls", "dep:webpki-roots"]
16-
1714
[dependencies]
18-
rustls = { workspace = true, features = ["ring", "std"], optional = true }
1915
serde.workspace = true
2016
serde_json.workspace = true
2117
stac.workspace = true
2218
stac-api.workspace = true
2319
thiserror.workspace = true
2420
tokio-postgres = { workspace = true, features = ["with-serde_json-1"] }
25-
tokio-postgres-rustls = { workspace = true, optional = true }
26-
webpki-roots = { workspace = true, optional = true }
2721

2822
[dev-dependencies]
2923
geojson.workspace = true

crates/pgstac/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,11 @@
7676
#![warn(missing_docs)]
7777

7878
mod page;
79-
#[cfg(feature = "tls")]
80-
mod tls;
8179

8280
pub use page::Page;
8381
use serde::{de::DeserializeOwned, Serialize};
8482
use stac_api::Search;
8583
use tokio_postgres::{types::ToSql, GenericClient, Row};
86-
#[cfg(feature = "tls")]
87-
pub use {tls::make_unverified_tls, tokio_postgres_rustls::MakeRustlsConnect};
8884

8985
/// Crate-specific error enum.
9086
#[derive(Debug, thiserror::Error)]

crates/pgstac/src/tls.rs

Lines changed: 0 additions & 106 deletions
This file was deleted.

crates/server/Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ rust-version.workspace = true
1313

1414
[features]
1515
axum = ["dep:axum", "dep:bytes", "dep:mime", "dep:tower-http"]
16-
pgstac = ["dep:pgstac", "dep:bb8", "dep:bb8-postgres", "dep:tokio-postgres"]
16+
pgstac = [
17+
"dep:bb8",
18+
"dep:bb8-postgres",
19+
"dep:pgstac",
20+
"dep:rustls",
21+
"dep:tokio-postgres",
22+
"dep:tokio-postgres-rustls",
23+
]
1724

1825
[dependencies]
1926
axum = { workspace = true, optional = true }
@@ -22,14 +29,16 @@ bb8-postgres = { workspace = true, optional = true }
2229
bytes = { workspace = true, optional = true }
2330
http.workspace = true
2431
mime = { workspace = true, optional = true }
25-
pgstac = { workspace = true, features = ["tls"], optional = true }
32+
pgstac = { workspace = true, optional = true }
33+
rustls = { workspace = true, optional = true }
2634
serde.workspace = true
2735
serde_json.workspace = true
2836
serde_urlencoded.workspace = true
2937
stac.workspace = true
3038
stac-api = { workspace = true, features = ["geo"] }
3139
thiserror.workspace = true
3240
tokio-postgres = { workspace = true, optional = true }
41+
tokio-postgres-rustls = { workspace = true, optional = true }
3342
tower-http = { workspace = true, features = ["cors", "trace"], optional = true }
3443
tracing.workspace = true
3544
url.workspace = true

crates/server/src/backend/pgstac.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
use crate::{Backend, Error, Result};
22
use bb8::Pool;
33
use bb8_postgres::PostgresConnectionManager;
4-
use pgstac::MakeRustlsConnect;
54
use pgstac::Pgstac;
5+
use rustls::{ClientConfig, RootCertStore};
66
use serde_json::Map;
77
use stac::{Collection, Item};
88
use stac_api::{ItemCollection, Items, Search};
99
use tokio_postgres::{
1010
tls::{MakeTlsConnect, TlsConnect},
1111
Socket,
1212
};
13+
use tokio_postgres_rustls::MakeRustlsConnect;
1314

1415
/// A backend for a [pgstac](https://github.com/stac-utils/pgstac) database.
1516
#[derive(Clone, Debug)]
@@ -40,7 +41,10 @@ impl PgstacBackend<MakeRustlsConnect> {
4041
pub async fn new_from_stringlike(
4142
params: impl ToString,
4243
) -> Result<PgstacBackend<MakeRustlsConnect>> {
43-
let tls = pgstac::make_unverified_tls();
44+
let config = ClientConfig::builder()
45+
.with_root_certificates(RootCertStore::empty())
46+
.with_no_client_auth();
47+
let tls = MakeRustlsConnect::new(config);
4448
PgstacBackend::new_from_stringlike_and_tls(params, tls).await
4549
}
4650
}
@@ -53,20 +57,6 @@ where
5357
<<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
5458
{
5559
/// Creates a new PgstacBackend from a string-like configuration and a tls.
56-
///
57-
/// # Examples
58-
///
59-
/// ```no_run
60-
/// use stac_server::PgstacBackend;
61-
///
62-
/// let tls = pgstac::make_unverified_tls();
63-
/// # tokio_test::block_on(async {
64-
/// let backend = PgstacBackend::new_from_stringlike_and_tls(
65-
/// "postgresql://username:password@localhost:5432/postgis",
66-
/// tls
67-
/// ).await.unwrap();
68-
/// # })
69-
/// ```
7060
pub async fn new_from_stringlike_and_tls(
7161
params: impl ToString,
7262
tls: Tls,

0 commit comments

Comments
 (0)