Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for client certs #2596

Merged
merged 28 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c0065bb
update tls - reword commit msg
rajatjindal Jun 24, 2024
52d9e01
add client_tls option to runtime config
rajatjindal Jun 24, 2024
4aa175f
add function to parse client tls opts
rajatjindal Jun 24, 2024
8477d37
add client tls options to TriggerAppEngine
rajatjindal Jun 24, 2024
b8402af
copy wasmtime default send request handler to spin
rajatjindal Jun 24, 2024
5d96bdd
move configuring client_tls_config to a separate fn
rajatjindal Jun 24, 2024
d64ea76
add client_tls_opts to HttpRuntimeData
rajatjindal Jun 24, 2024
3a97ef1
modify default_send_request_handler to allow use of client_tls_opts
rajatjindal Jun 24, 2024
419848d
use spin's version of default_send_request_handler with client_tls_opts
rajatjindal Jun 24, 2024
19e4dff
address review comments
rajatjindal Jun 25, 2024
1b74452
parse hosts as Authority and use that as key for client tls opts
rajatjindal Jun 25, 2024
dc78e99
remove into_iter to fix lint issue
rajatjindal Jun 25, 2024
108e2a3
add couple of tests for parse_client_tls_opts
rajatjindal Jun 26, 2024
71ea773
use iterator for creating host -> client opts map
rajatjindal Jun 26, 2024
1527ca1
throw error if adding cert to trust store fails
rajatjindal Jun 26, 2024
e4094d6
add knob to use ca_webpki_roots and defaults
rajatjindal Jun 26, 2024
58a3595
add testcases for client tls options in runtime config
rajatjindal Jun 26, 2024
3cad9dd
store parsed value of ca_webpki_roots in ParsedClientTlsOpts
rajatjindal Jun 26, 2024
ed1077f
parse component-id as spin_serde::KebabId to catch invalid ids early
rajatjindal Jun 26, 2024
b97f09c
add an exception for lint false positive mutable_key_type
rajatjindal Jun 26, 2024
bb3e1ee
fix lint warnings
rajatjindal Jun 26, 2024
9bef9d2
fix lint warnings
rajatjindal Jun 26, 2024
857e39a
remove use of unwrap from load tls certs/key fns
rajatjindal Jun 26, 2024
b64c582
return error instead of unwrap
rajatjindal Jun 26, 2024
cd2c096
ran make update-cargo-locks
rajatjindal Jun 27, 2024
8f66682
change tls opts logic to ensure first entry wins
rajatjindal Jul 1, 2024
881c3bb
remove duplicate into_iter()
rajatjindal Jul 1, 2024
8604bb2
address final review nits
rajatjindal Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 28 additions & 90 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions crates/trigger-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ http-body-util = { workspace = true }
indexmap = "1"
outbound-http = { path = "../outbound-http" }
percent-encoding = "2"
rustls-pemfile = "0.3.0"
rustls = { version = "0.22.0" }
rustls-pemfile = "2.1.2"
rustls-pki-types = "1.7"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
spin-app = { path = "../app" }
Expand All @@ -33,13 +35,14 @@ spin-world = { path = "../world" }
terminal = { path = "../terminal" }
tls-listener = { version = "0.10.0", features = ["rustls"] }
tokio = { version = "1.23", features = ["full"] }
tokio-rustls = { version = "0.23.2" }
tokio-rustls = { version = "0.25.0" }
url = "2.4.1"
tracing = { workspace = true }
wasmtime = { workspace = true }
wasmtime-wasi = { workspace = true }
wasmtime-wasi-http = { workspace = true }
wasi-common-preview1 = { workspace = true }
webpki-roots = { version = "0.26.0" }

[dev-dependencies]
criterion = { version = "0.3.5", features = ["async_tokio"] }
Expand Down
8 changes: 8 additions & 0 deletions crates/trigger-http/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ impl HttpExecutor for HttpHandlerExecutor {

set_http_origin_from_request(&mut store, engine.clone(), self, &req);

// set the client tls options for the current component_id.
// The OutboundWasiHttpHandler in this file is only used
// when making http-request from a http-trigger component.
// The outbound http requests from other triggers such as Redis
// uses OutboundWasiHttpHandler defined in spin_core crate.
store.as_mut().data_mut().as_mut().client_tls_opts =
engine.get_client_tls_opts(component_id);

let resp = match ty {
HandlerType::Spin => {
Self::execute_spin(store, instance, base, route_match, req, client_addr)
Expand Down
Loading
Loading