Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Do it with me now. loooooooong sigh
Okay, rust depedencies are a headache, we know this.
Updating AWS deps in #1019 brought in a lot of newer stuff.
At this point, we're specifically concerned with
rustls
.The default provider
<0.23
wasring
.0.24
defaults toaws-lc-rs
. It's faster, more compliant, all that good stuff.But this poses a problem to us, what to use when both
aws-lc-rs
andring
are present in the dependency tree?If they both try to install themselves as the global
CryptoProvider
, that's no good.The state of rust deps that depend on TLS is slowly moving over to
aws-lc-rs
, but not quite there. So we have to make the decision in our runtime.The option I don't like
We could manually install
aws-lc-rs
in themain()
function if every bin we build.But this won't enable for tests, and we won't know if there's a conflicting backend installed until runtime.
And we would need to handle the case where someone installed before our main function could run.
I didn't do that.
The option I did
A new workspace was added,
tls-init
.It uses
ctor
to run a constructor function when the crate is included anywhere.It will only run a single time no matter how many times it's included, so we don't need to worry about multiple levels of dependencies including
tls-init
.For any crate that uses TLS we need to include it in
Cargo.toml
And include the crate in
lib.rs
.extern
ing the crate is required so the linker doesn't optimize the dependency away.Now, when any workspace is loaded or depended on that requires TLS, the first thing that happens is we install
aws-lc-rs
as theCryptoProvider
backend.Can we be sure?
I'm not sure how to be totally sure.
But
tls_init
also provides a test that can be included in workspaces that will hopefully catch if another dependency includesring
and it tries to be installed as the backend.This inlines the tests into the workspace to run alongside all of it's dependencies.
Other
backon
was updated because there was a breaking change between0.4
and0.5
. But weirdly, not>1
. Also it was easy, and a dev-dependency.