From 8db37baf93d3c229216705d59a64a9dbdf71fe38 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 17 Aug 2021 19:14:52 -0400 Subject: [PATCH] Fixing issue when local has no openssl certs. --- Cargo.lock | 1 + Cargo.toml | 1 + src/main.rs | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4cdcc47f6..515b0c4f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1880,6 +1880,7 @@ dependencies = [ "lemmy_websocket", "log", "openssl", + "openssl-probe", "reqwest", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index be1fd4128..88c4e1cc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,6 +63,7 @@ activitystreams = "0.7.0-alpha.11" actix-rt = { version = "2.2.0", default-features = false } serde_json = { version = "1.0.66", features = ["preserve_order"] } clokwerk = "0.3.5" +openssl-probe = "0.1.2" [dev-dependencies.cargo-husky] version = "1.5.0" diff --git a/src/main.rs b/src/main.rs index 504ccc80e..58d5a129b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,8 @@ use lemmy_utils::{ LemmyError, }; use lemmy_websocket::{chat_server::ChatServer, LemmyContext}; -use reqwest::Client; +use log::warn; +use reqwest::{Client, ClientBuilder}; use std::{sync::Arc, thread}; use tokio::sync::Mutex; @@ -67,12 +68,21 @@ async fn main() -> Result<(), LemmyError> { let activity_queue = create_activity_queue(); + let client = if !openssl_probe::has_ssl_cert_env_vars() { + warn!("No OpenSSL certs found, accepting invalid certs."); + ClientBuilder::new() + .danger_accept_invalid_certs(true) + .build()? + } else { + Client::default() + }; + let chat_server = ChatServer::startup( pool.clone(), rate_limiter.clone(), |c, i, o, d| Box::pin(match_websocket_operation(c, i, o, d)), |c, i, o, d| Box::pin(match_websocket_operation_crud(c, i, o, d)), - Client::default(), + client.clone(), activity_queue.clone(), ) .start(); @@ -82,7 +92,7 @@ async fn main() -> Result<(), LemmyError> { let context = LemmyContext::create( pool.clone(), chat_server.to_owned(), - Client::default(), + client.clone(), activity_queue.to_owned(), ); let rate_limiter = rate_limiter.clone();