You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to connect to my database using AsyncPgConnection I get a SSL error but it works using PgConnection
Setup
My postgres URL is just a simple username/password postgres:// url with no additional query params.
Cargo.toml
[dependencies]
diesel = { version = "2.0.3", features = ["postgres", "r2d2", "extras", "chrono", "uuid"] }
diesel-async = { version = "0.2.1", features = ["postgres", "bb8"] }
dotenv = "0.15.0"serde = { version = "1.0.159", features = ["derive"]}
serde_json = "1.0.95"chrono = { version = "0.4.24", features = ["serde"] }
bb8 = "0.8"axum = "0.6.12"axum-macros = "0.3.7"tokio = { version = "1.27.0", features = ["full"] }
tracing = "0.1.37"tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
Steps to reproduce
Using PgConnection:
#[tokio::main]asyncfnmain(){dotenv().ok();let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");letmut connection = PgConnection::establish(&database_url).unwrap();println!("Established!");let orgs = orgs::table.load::<Org>(&mut connection).unwrap();println!("{:?}", orgs);}
Output:
Established!
[]
Using AsyncPgConnection:
#[tokio::main]asyncfn main(){dotenv().ok();let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");letmut connection = AsyncPgConnection::establish(&database_url).await.unwrap();println!("Established!");let orgs = orgs::table.load::<Org>(&mut connection).await.unwrap();println!("{:?}", orgs);
Output
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CouldntSetupConfiguration(DatabaseError(Unknown, "SSL/TLS required"))', src\main.rs:27:76
Checklist
I have already looked over the issue tracker for similar possible closed issues.
This issue can be reproduced on Rust's stable channel. (Your issue will be
closed if this is not the case)
This issue can be reproduced without requiring a third party crate
The text was updated successfully, but these errors were encountered:
This is expected behavior as tokio-postgres does not provide support for TLS/SSL connections by default. You need to setup that by including additional dependencies. As there are multiple options there I choose to not include that directly in diesel. You can construct a AsyncPgConnection for a tokio-postgresClient that supports TLS/SSL connections via AsyncPgConnection::try_from.
When trying to connect to my database using
AsyncPgConnection
I get a SSL error but it works usingPgConnection
Setup
My postgres URL is just a simple username/password postgres:// url with no additional query params.
Cargo.toml
Steps to reproduce
Using
PgConnection
:Output:
Using
AsyncPgConnection
:Output
Checklist
closed if this is not the case)
The text was updated successfully, but these errors were encountered: