Skip to content

Commit e705ca2

Browse files
committed
fix hyper-simulator-http startup args
1 parent 1361676 commit e705ca2

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

http/src/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct HttpArgs {
2626
http_listen_address: SocketAddr,
2727

2828
/// Should the HTTP server terminate TLS connections?
29-
#[arg(long, action, env = "CLIENT_SIMULATOR_HTTP_TLS")]
29+
#[arg(long, action, default_value_t = false, env = "CLIENT_SIMULATOR_HTTP_TLS")]
3030
tls: bool,
3131
}
3232

@@ -38,11 +38,11 @@ struct Args {
3838

3939
/// Path to the X.509 public key certificate in DER encoding.
4040
#[arg(long)]
41-
certificate: PathBuf,
41+
certificate: Option<PathBuf>,
4242

4343
/// Path to the private key for the X.509 certificate in DER encoding.
4444
#[arg(long)]
45-
private_key: PathBuf,
45+
private_key: Option<PathBuf>,
4646
}
4747

4848
fn init_logging() {
@@ -62,7 +62,13 @@ async fn start_server(args: Args) -> Result<()> {
6262
tracing::info!("listening on {}", args.http.http_listen_address);
6363

6464
if args.http.tls {
65-
let rustls_config = RustlsConfig::from_pem_file(args.certificate, args.private_key).await?;
65+
let Some(cert_path) = args.certificate else {
66+
eyre::bail!("TLS is enabled but no certificate path was provided");
67+
};
68+
let Some(private_key) = args.private_key else {
69+
eyre::bail!("TLS is enabled but no private key path was provided");
70+
};
71+
let rustls_config = RustlsConfig::from_pem_file(cert_path, private_key).await?;
6672
axum_server::bind_rustls(args.http.http_listen_address, rustls_config)
6773
.serve(app.into_make_service())
6874
.await?;

0 commit comments

Comments
 (0)