mirror of
https://github.com/ilyakooo0/reshape.git
synced 2024-10-27 02:28:50 +03:00
Add TLS support
This commit is contained in:
parent
c8cd6f438e
commit
05753c09c2
@ -13,6 +13,8 @@ rust-version = "1.70"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
postgres = { version = "0.19.2", features = ["with-serde_json-1"] }
|
postgres = { version = "0.19.2", features = ["with-serde_json-1"] }
|
||||||
|
openssl = { version = "0.10.64", features = ["vendored"] }
|
||||||
|
postgres-openssl = "0.5.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
typetag = "0.1.7"
|
typetag = "0.1.7"
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use std::{cmp::min, time::Duration};
|
use std::{cmp::min, time::Duration};
|
||||||
|
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use postgres::{types::ToSql, NoTls, Row};
|
use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
|
||||||
|
use postgres::{types::ToSql, Row};
|
||||||
|
use postgres_openssl::MakeTlsConnector;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
|
||||||
// DbLocker wraps a regular DbConn, only allowing access using the
|
// DbLocker wraps a regular DbConn, only allowing access using the
|
||||||
@ -25,7 +27,10 @@ impl DbLocker {
|
|||||||
const LOCK_KEY: i64 = 4036779288569897133;
|
const LOCK_KEY: i64 = 4036779288569897133;
|
||||||
|
|
||||||
pub fn connect(config: &postgres::Config) -> anyhow::Result<Self> {
|
pub fn connect(config: &postgres::Config) -> anyhow::Result<Self> {
|
||||||
let mut pg = config.connect(NoTls)?;
|
let mut builder = SslConnector::builder(SslMethod::tls())?;
|
||||||
|
builder.set_verify(SslVerifyMode::NONE);
|
||||||
|
let connector = MakeTlsConnector::new(builder.build());
|
||||||
|
let mut pg = config.connect(connector)?;
|
||||||
|
|
||||||
// When running DDL queries that acquire locks, we risk causing a "lock queue".
|
// When running DDL queries that acquire locks, we risk causing a "lock queue".
|
||||||
// When attempting to acquire a lock, Postgres will wait for any long running queries to complete.
|
// When attempting to acquire a lock, Postgres will wait for any long running queries to complete.
|
||||||
|
Loading…
Reference in New Issue
Block a user