Skip to content

Commit

Permalink
Fix warns logging in HTTPS setup #786
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Jan 10, 2024
1 parent 8797baf commit a0fb231
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions server/src/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
//! checks if certificates are not outdated,
//! persists files on disk.
use crate::errors::AtomicServerResult;
use actix_web::{dev::ServerHandle, App, HttpServer};
use std::{
fs::{self, File},
io::BufReader,
path::PathBuf,
};
use tracing::{info, warn};

use crate::errors::AtomicServerResult;
/// Create RUSTLS server config from certificates in config dir
pub fn get_https_config(
config: &crate::config::Config,
Expand Down Expand Up @@ -87,17 +89,11 @@ pub fn should_renew_certs_check(config: &crate::config::Config) -> AtomicServerR
Ok(expired)
}

use actix_web::{dev::ServerHandle, App, HttpServer};
use instant_acme::{KeyAuthorization, OrderStatus};
use tracing::{info, log::warn};

use std::sync::mpsc;

/// Starts an HTTP Actix server for HTTPS certificate initialization
async fn cert_init_server(
config: &crate::config::Config,
challenge: &instant_acme::Challenge,
key_auth: &KeyAuthorization,
key_auth: &instant_acme::KeyAuthorization,
) -> AtomicServerResult<ServerHandle> {
let address = format!("{}:{}", config.opts.ip, config.opts.port);
warn!("Server temporarily running in HTTP mode at {}, running Let's Encrypt Certificate initialization...", address);
Expand All @@ -120,7 +116,7 @@ async fn cert_init_server(
// let challenge_file_content = format!("{}.{}", challenge.token, key_auth.as_str());
fs::write(challenge_path, key_auth.as_str())?;

let (tx, rx) = mpsc::channel();
let (tx, rx) = std::sync::mpsc::channel();

std::thread::spawn(move || {
actix_web::rt::System::new().block_on(async move {
Expand Down Expand Up @@ -175,6 +171,8 @@ async fn cert_init_server(

/// Sends a request to LetsEncrypt to create a certificate
pub async fn request_cert(config: &crate::config::Config) -> AtomicServerResult<()> {
use instant_acme::OrderStatus;

let challenge_type = if config.opts.https_dns {
info!("Using DNS-01 challenge");
instant_acme::ChallengeType::Dns01
Expand Down Expand Up @@ -289,8 +287,7 @@ pub async fn request_cert(config: &crate::config::Config) -> AtomicServerResult<
let state = loop {
actix::clock::sleep(delay).await;
let state = order.state();
if let instant_acme::OrderStatus::Ready | instant_acme::OrderStatus::Invalid = state.status
{
if let OrderStatus::Ready | OrderStatus::Invalid = state.status {
info!("order state: {:#?}", state);
break state;
}
Expand Down

0 comments on commit a0fb231

Please sign in to comment.