Skip to content

Commit

Permalink
TLS Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoff97 committed Sep 27, 2024
1 parent a007a1a commit 977a38e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions backend-rust/src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::f32;
use std::{
cmp::{max, min},
collections::HashMap,
fs,
hash::{Hash, Hasher},
io::Cursor,
};
Expand All @@ -17,10 +17,12 @@ use quick_xml::{
Writer,
};
use rocket::{
config::TlsConfig,
fs::FileServer,
http::ContentType,
response::Redirect,
serde::{json::Json, Serialize},
Config,
};

use ndarray::{s, Array2};
Expand Down Expand Up @@ -251,7 +253,6 @@ fn get_flight_cone(
start_distance,
);

let (lats, lons) = grid.get_coordinates_for_indices();
let resolution = grid.get_angular_resolution();

let mut response = FlightConeResponse {
Expand Down Expand Up @@ -638,7 +639,23 @@ fn get_kml<'a>(

#[launch]
fn rocket() -> _ {
rocket::build()
let mut tls_config = None;
let metadata = fs::metadata("/app/ssl/certs.pem");
if metadata.is_ok() && metadata.unwrap().is_file() {
println!("Running with TLS enabled!");

tls_config = Some(TlsConfig::from_paths(
"/app/ssl/fullchain.pem",
"/app/ssl/privkey.pem",
));
}

let config = Config {
tls: tls_config,
..Default::default()
};

rocket::custom(config)
.mount("/", routes![index])
.mount("/", routes![get_flight_cone])
.mount("/", routes![get_agl_image])
Expand Down

0 comments on commit 977a38e

Please sign in to comment.