Skip to content

Commit 4a56406

Browse files
authored
Merge pull request #23 from ananace/postgres-ssl
Support postgres with SSL requirements
2 parents 1aac27e + dc635bd commit 4a56406

File tree

3 files changed

+111
-11
lines changed

3 files changed

+111
-11
lines changed

Cargo.lock

Lines changed: 102 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ edition = "2018"
99
clap = "2.33.0"
1010
indicatif = "0.14.0"
1111
jemallocator = "0.3.2"
12+
openssl = "0.10.32"
1213
postgres = "0.17.0"
14+
postgres-openssl = "0.3.0"
1315
rand = "0.7.2"
1416
rayon = "1.3.0"
1517
string_cache = "0.8.0"

src/database.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
use indicatif::{ProgressBar, ProgressStyle};
1616
use postgres::{fallible_iterator::FallibleIterator, Client};
17+
use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
18+
use postgres_openssl::MakeTlsConnector;
1719
use rand::{distributions::Alphanumeric, thread_rng, Rng};
1820
use std::{borrow::Cow, collections::BTreeMap, fmt, iter};
1921

@@ -26,7 +28,11 @@ pub fn get_data_from_db(
2628
room_id: &str,
2729
max_state_group: Option<i64>,
2830
) -> BTreeMap<i64, StateGroupEntry> {
29-
let mut client = Client::connect(db_url, postgres::NoTls).unwrap();
31+
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
32+
builder.set_verify(SslVerifyMode::NONE);
33+
let connector = MakeTlsConnector::new(builder.build());
34+
35+
let mut client = Client::connect(db_url, connector).unwrap();
3036

3137
let mut state_group_map = get_initial_data_from_db(&mut client, room_id, max_state_group);
3238

0 commit comments

Comments
 (0)