Skip to content

Commit

Permalink
feat: Accept invalid hostnames (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
darioAnongba authored Aug 12, 2024
1 parent fd6beb8 commit 3d0743a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dotenv = "0.15.0"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["json", "env-filter"] }
jsonwebtoken = "9.3.0"
reqwest = "=0.11.20"
reqwest = { version = "0.12.5", features = ["json"] }
uuid = { version = "1.9.1", features = ["v4", "serde"] }
chrono = "0.4.38"
thiserror = "1.0.61"
Expand Down
1 change: 1 addition & 0 deletions config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ connect_timeout = "5s"
timeout = "30s"
connection_verbose = true
accept_invalid_certs = false
accept_invalid_hostnames = false
maxfeepercent = 0.5
payment_timeout = "60s"
payment_exemptfee = 5000
Expand Down
5 changes: 4 additions & 1 deletion src/infra/lightning/cln/cln_rest_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct ClnRestClientConfig {
#[serde(deserialize_with = "deserialize_duration")]
pub timeout: Duration,
pub accept_invalid_certs: bool,
pub accept_invalid_hostnames: bool,
pub maxfeepercent: Option<f64>,
#[serde(deserialize_with = "deserialize_duration")]
pub payment_timeout: Duration,
Expand Down Expand Up @@ -80,7 +81,9 @@ impl ClnRestClient {
let ca_certificate = Self::read_ca(ca_cert_path)
.await
.map_err(|e| LightningError::ReadCertificates(e.to_string()))?;
client_builder = client_builder.add_root_certificate(ca_certificate);
client_builder = client_builder
.add_root_certificate(ca_certificate)
.danger_accept_invalid_hostnames(config.accept_invalid_hostnames);
}

let client = client_builder
Expand Down
3 changes: 2 additions & 1 deletion src/infra/lightning/cln/cln_websocket_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ pub async fn connect_websocket(
.map_err(|e| LightningError::ReadCertificates(e.to_string()))?;
let tls_connector = TlsConnector::builder()
.add_root_certificate(ca_certificate)
.danger_accept_invalid_hostnames(config.accept_invalid_hostnames)
.build()
.map_err(|e| LightningError::TLSConfig(e.to_string()))?;
client_builder = client_builder.tls_config(tls_connector);
client_builder = client_builder.tls_config(tls_connector.clone());
}

if config.accept_invalid_certs {
Expand Down

0 comments on commit 3d0743a

Please sign in to comment.