aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2021-08-28 18:41:32 +0000
committerGitHub <noreply@github.com>2021-08-28 18:41:32 +0000
commit1c344f2625c1a7a4bfdf20fd891dd86f84ff8b76 (patch)
tree4e08f16c25c3f7080c454bead5791880587077e7 /src/config.rs
parent(cargo-release) start next development iteration 0.15.1-alpha.0 (diff)
parentSwitch TLS conditional compilation to feature (diff)
downloadminiserve-1c344f2625c1a7a4bfdf20fd891dd86f84ff8b76.tar.gz
miniserve-1c344f2625c1a7a4bfdf20fd891dd86f84ff8b76.zip
Merge pull request #580 from svenstaro/conditional-tls
Conditionally enable TLS only on supported platforms
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 6eeafef..e2b4c3a 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -7,6 +7,8 @@ use std::{
use anyhow::{anyhow, Context, Result};
use http::HeaderMap;
+
+#[cfg(feature = "tls")]
use rustls::internal::pemfile::{certs, pkcs8_private_keys};
use crate::{args::CliArgs, auth::RequiredAuth};
@@ -95,7 +97,11 @@ pub struct MiniserveConfig {
pub hide_version_footer: bool,
/// If set, use provided rustls config for TLS
+ #[cfg(feature = "tls")]
pub tls_rustls_config: Option<rustls::ServerConfig>,
+
+ #[cfg(not(feature = "tls"))]
+ pub tls_rustls_config: Option<()>,
}
impl MiniserveConfig {
@@ -131,6 +137,7 @@ impl MiniserveConfig {
_ => args.port,
};
+ #[cfg(feature = "tls")]
let tls_rustls_server_config = if let (Some(tls_cert), Some(tls_key)) =
(args.tls_cert, args.tls_key)
{
@@ -150,6 +157,10 @@ impl MiniserveConfig {
} else {
None
};
+
+ #[cfg(not(feature = "tls"))]
+ let tls_rustls_server_config = None;
+
Ok(MiniserveConfig {
verbose: args.verbose,
path: args.path.unwrap_or_else(|| PathBuf::from(".")),