Skip to content

Commit 3cad9dd

Browse files
committed
store parsed value of ca_webpki_roots in ParsedClientTlsOpts
Signed-off-by: Rajat Jindal <[email protected]>
1 parent 58a3595 commit 3cad9dd

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

crates/trigger-http/src/lib.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,18 +1184,7 @@ fn get_client_tls_config_for_authority(
11841184
}
11851185
};
11861186

1187-
let custom_root_ca_provided = client_tls_opts_for_host.custom_root_ca.is_some();
1188-
1189-
// use_ca_webpki_roots is true if
1190-
// 1. ca_webpki_roots is explicitly true in runtime config OR
1191-
// 2. custom_root_ca is not provided
1192-
//
1193-
// if custom_root_ca is provided, use_ca_webpki_roots defaults to false
1194-
let use_ca_webpki_roots = client_tls_opts_for_host
1195-
.ca_webpki_roots
1196-
.unwrap_or(if custom_root_ca_provided { false } else { true });
1197-
1198-
let mut root_cert_store = if use_ca_webpki_roots {
1187+
let mut root_cert_store = if client_tls_opts_for_host.ca_webpki_roots {
11991188
ca_webpki_roots
12001189
} else {
12011190
rustls::RootCertStore::empty()

crates/trigger/src/runtime_config.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ ca_roots_file = "{}"
712712
let component_no1_host_client_tls_opts = component_no1_client_tls_opts
713713
.get(&"localhost:6551".parse::<Authority>().unwrap())
714714
.unwrap();
715-
715+
716716
// verify that the last client_tls block wins for same component-id and host combination
717717
assert!(component_no1_host_client_tls_opts.custom_root_ca.is_some());
718718
}
@@ -740,7 +740,7 @@ pub struct ParsedClientTlsOpts {
740740
pub custom_root_ca: Option<Vec<rustls_pki_types::CertificateDer<'static>>>,
741741
pub cert_chain: Option<Vec<rustls_pki_types::CertificateDer<'static>>>,
742742
pub private_key: Option<Arc<rustls_pki_types::PrivateKeyDer<'static>>>,
743-
pub ca_webpki_roots: Option<bool>,
743+
pub ca_webpki_roots: bool,
744744
}
745745

746746
fn parse_client_tls_opts(inp: &ClientTlsOpts) -> Result<ParsedClientTlsOpts, anyhow::Error> {
@@ -772,12 +772,23 @@ fn parse_client_tls_opts(inp: &ClientTlsOpts) -> Result<ParsedClientTlsOpts, any
772772
})
773773
.collect::<Result<Vec<Authority>, anyhow::Error>>()?;
774774

775+
let custom_root_ca_provided = custom_root_ca.is_some();
776+
777+
// use_ca_webpki_roots is true if
778+
// 1. ca_webpki_roots is explicitly true in runtime config OR
779+
// 2. custom_root_ca is not provided
780+
//
781+
// if custom_root_ca is provided, use_ca_webpki_roots defaults to false
782+
let ca_webpki_roots =
783+
inp.ca_webpki_roots
784+
.unwrap_or(if custom_root_ca_provided { false } else { true });
785+
775786
Ok(ParsedClientTlsOpts {
776787
hosts: parsed_hosts,
777788
components: inp.component_ids.clone(),
778789
custom_root_ca,
779790
cert_chain,
780791
private_key,
781-
ca_webpki_roots: inp.ca_webpki_roots,
792+
ca_webpki_roots,
782793
})
783794
}

0 commit comments

Comments
 (0)