fix: postgres ssl mode (#2861)

This commit is contained in:
HugoCasa
2023-12-15 15:15:55 +01:00
committed by GitHub
parent 65e18abe7d
commit 6c809b8630
+6 -1
View File
@@ -67,7 +67,12 @@ pub async fn do_postgresql(
} else {
return Err(Error::BadRequest("Missing database argument".to_string()));
};
let sslmode = database.sslmode.unwrap_or("prefer".to_string());
let sslmode = match database.sslmode.as_deref() {
Some("allow") => "prefer".to_string(),
Some("verify-ca") | Some("verify-full") => "require".to_string(),
Some(s) => s.to_string(),
None => "prefer".to_string(),
};
let database_string = format!(
"postgres://{user}:{password}@{host}:{port}/{dbname}?sslmode={sslmode}",
user = encode(&database.user.unwrap_or("postgres".to_string())),