Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ spin-telemetry = { path = "crates/telemetry", features = [
"tracing-log-compat",
] }
spin-templates = { path = "crates/templates" }
spin-tls = { path = "crates/tls" }
spin-trigger = { path = "crates/trigger" }
spin-trigger-http = { path = "crates/trigger-http" }
spin-trigger-redis = { path = "crates/trigger-redis" }
Expand Down
15 changes: 15 additions & 0 deletions crates/tls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "spin-tls"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true

[dependencies]
rustls = { workspace = true }

[lints]
workspace = true
15 changes: 15 additions & 0 deletions crates/tls/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::sync::Once;

static INSTALL_DEFAULT_CRYPTO_PROVIDER: Once = Once::new();

/// Install Spin's process-wide rustls crypto provider.
///
/// This is idempotent for Spin's own duplicate calls from `main` and the trigger,
/// but fails loudly if something else installed a rustls provider first.
pub fn install_default_crypto_provider() {
INSTALL_DEFAULT_CRYPTO_PROVIDER.call_once(|| {
rustls::crypto::ring::default_provider()
.install_default()
.expect("failed to install rustls ring crypto provider");
});
}
1 change: 1 addition & 0 deletions crates/trigger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ spin-factor-wasi = { path = "../factor-wasi" }
spin-factors = { path = "../factors" }
spin-factors-executor = { path = "../factors-executor" }
spin-telemetry = { path = "../telemetry" }
spin-tls = { path = "../tls" }
spin-world = { path = "../world" }
tokio = { workspace = true, features = ["fs", "rt"] }
tracing = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/trigger/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ pub struct NoCliArgs;
impl<T: Trigger<B::Factors>, B: RuntimeFactorsBuilder> FactorsTriggerCommand<T, B> {
/// Create a new TriggerExecutorBuilder from this TriggerExecutorCommand.
pub async fn run(self) -> Result<()> {
spin_tls::install_default_crypto_provider();
// Handle --help-args-only
if self.help_args_only {
Self::command()
Expand Down
1 change: 1 addition & 0 deletions src/bin/spin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use spin_cli::subprocess::ExitStatusError;

#[tokio::main]
async fn main() {
spin_tls::install_default_crypto_provider();
if let Err(err) = spin_cli::run().await {
let code = match err.downcast_ref::<ExitStatusError>() {
// If we encounter an `ExitStatusError` it means a subprocess has already
Expand Down
Loading