Skip to content

Switch rustls crypto provider from ring to aws_lc_rs - #3654

Open
ChihweiLHBird wants to merge 1 commit into
spinframework:mainfrom
ChihweiLHBird:zhiwei/ring-to-aws-lc-rs
Open

Switch rustls crypto provider from ring to aws_lc_rs#3654
ChihweiLHBird wants to merge 1 commit into
spinframework:mainfrom
ChihweiLHBird:zhiwei/ring-to-aws-lc-rs

Conversation

@ChihweiLHBird

@ChihweiLHBird ChihweiLHBird commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Install aws_lc_rs as the process-wide provider at startup. ring is still compiled via transitive rustls features; removing it is a follow-up.

Replace the install helper with spin_tls::get_or_install_default_crypto_provider(), which returns the installed default, respecting a provider installed by embedders (the old helper would panic), and installs aws-lc-rs if none is set. The outbound client and trigger-http server TLS configs now build with aws_lc_rs provider explicitly.

Partially fix #3502

Install aws-lc-rs as the process-wide provider at startup. ring is still compiled via transitive rustls features; removing it is a follow-up.

Since both provider features are now enabled, rustls auto-detection would panic on paths that bypass Spin's entrypoints. Replace the install helper with spin_tls::get_or_install_default_crypto_provider(), which returns the installed default - respecting a provider installed by embedders (the old helper would panic) - and installs aws-lc-rs if none is set. The outbound client and trigger-http server TLS configs now build with this provider explicitly.

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@itowlson
itowlson requested review from lann and rylev August 9, 2026 19:35
@lann

lann commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

rustls auto-detection would panic on paths that bypass Spin's entrypoints

Could you say more about this? Where would one need to bypass Spin's entrypoints? 🤔

@ChihweiLHBird

ChihweiLHBird commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

rustls auto-detection would panic on paths that bypass Spin's entrypoints

Could you say more about this? Where would one need to bypass Spin's entrypoints? 🤔

Sorry... this is still a draft. The scenario in my mind was if another thing uses Spin as a crate and install ring as default. I know it's not supposed to be used this way, but in theory it might happen. So, I left that in draft and will refine it later.

@lann

lann commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

If something is embedding spin it should be able to pick the provider. If we're changing the default for spin up then that should just be scoped to the spin binary crate I think.

@ChihweiLHBird

Copy link
Copy Markdown
Contributor Author

@lann the original way expects the default is not installed:

rustls::crypto::ring::default_provider()
    .install_default()
    .expect("failed to install rustls ring crypto provider");

It's from my previous PR #3590

The implementation in this PR is theoradically safer even though the panic scenario is very unlikely to be triggerred.

@ChihweiLHBird ChihweiLHBird changed the title Switch rustls crypto provider from ring to aws-lc-rs Switch rustls crypto provider from ring to aws_lc_rs Aug 10, 2026
@lann

lann commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Right but that is only called from spin trigger implementations (which are effectively the root binary crate in this case).

@ChihweiLHBird

ChihweiLHBird commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@lann Sorry for the confusion. I looked into it again, and found my earlier explanation was wrong.

Flipping the workspace rustls feature to aws_lc_rs does not remove ring, so without these guards of installing default and build ClientConfig with a specific provider via builder_with_provider, it may panic because 2 providers are compiled in. In many code paths, e.g. some spin tests, who doesn't call the install default helper, will panic, if without builder_with_provider.

Four tests in crates/factor-outbound-networking/src/tls.rs and tests/factor_test.rs all build a ClientConfig without going through a Spin entrypoint. That's what the builder_with_provider calls guard.

I can also split the helper into install_default_crypto_provider() (entrypoints only) and default_crypto_provider() for the config builders. Does that sound like a good idea?

@ChihweiLHBird
ChihweiLHBird marked this pull request as ready for review August 11, 2026 06:07
@ChihweiLHBird
ChihweiLHBird marked this pull request as draft August 11, 2026 06:37
@ChihweiLHBird
ChihweiLHBird marked this pull request as ready for review August 12, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FIPS Support

2 participants