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
psql (13.5 (Ubuntu 13.5-0ubuntu0.21.10.1), server 14.2 (Ubuntu 14.2-1.pgdg20.04+1))
WARNING: psql major version 13, server major version 14.
Some psql features might not work.
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
my_db_name=#
However, it doesn't play as nicely in sqlx land:
Cargo.toml
[package]
name = "backend"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sqlx = { version = "0.5", features = [ "runtime-tokio-native-tls", "postgres" ] }
tokio = { version = "1", features = ["full"] }
main.rs --slighly adapted from the README.md example:
use sqlx::postgres::PgPoolOptions;
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), sqlx::Error> {
assert!(Path::new("root.crt").exists());
assert!(Path::new("pg_client.key").exists());
assert!(Path::new("pg_client.crt").exists());
let pool = PgPoolOptions::new()
.max_connections(5)
.connect(
"postgresql://my_db_udser@localhost:5432/my_db_name?sslmode=verify-ca&sslrootcert=root.crt&sslkey=pg_client.key&sslcert=pg_client.crt")
.await?;
// Make a simple query to return the given parameter (use a question mark `?` instead of `$1` for MySQL)
let row: (i64,) = sqlx::query_as("SELECT $1")
.bind(150_i64)
.fetch_one(&pool)
.await?;
assert_eq!(row.0, 150);
Ok(())
}
I've got a PostgreSQL instance set up to only accept encrypted connections with certificates.
I am able to connect to it via
psql
just fine:The session starts without issues:
However, it doesn't play as nicely in sqlx land:
Cargo.toml
main.rs --slighly adapted from the README.md example:
produces the error:
What could be causing this?
The text was updated successfully, but these errors were encountered: