Switch rustls crypto provider from ring to aws_lc_rs - #3654
Conversation
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>
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. |
|
If something is embedding spin it should be able to pick the provider. If we're changing the default for |
|
@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. |
|
Right but that is only called from spin trigger implementations (which are effectively the root binary crate in this case). |
|
@lann Sorry for the confusion. I looked into it again, and found my earlier explanation was wrong. Flipping the workspace Four tests in I can also split the helper into |
Install
aws_lc_rsas the process-wide provider at startup. ring is still compiled via transitiverustlsfeatures; 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 andtrigger-httpserver TLS configs now build withaws_lc_rsprovider explicitly.Partially fix #3502