Panic if no trust anchors are found #125
Merged
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.
It looks like hyper-rustls wants to abstract over the differences between using the webpki-roots and rustls-native-certs backend, but this just bit me in an unobvious way that I think could be improved. I'm building a scratch container, meaning it only contains the statically linked binary and nothing else. One of my dependencies uses hyper-rustls as a dependency with the default features. As a result, (a) rustls-native-certs returns an empty
RootCertStore
without flagging that there might be an issue, (b) when hyper tries to connect through theConnector
, it fails with awebpki::Error::UnknownIssuer
. And, this doesn't happen when testing outside the containerized environment, but fails inside the container.I feel like something should probably generate an error or panic if this happens, but I'm not sure which level of the stack is most appropriate. Since the return value of
rustls_native_certs::load_native_certs()
is technically correct, I feel like the problem here is in how hyper-rustls tries to abstract over the differences.The solution implemented here is to have hyper-rustls panic if
Connector::new()
doesn't find any trust anchors; since it can already panic when it is unable to access a native cert store, this seems like an okay solution. Alternatively, mayberustls_native_certs::load_native_certs()
should return an error if it doesn't find anything? This is technically correct but not very useful behavior.