Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cross-platform support for SSL_CERT_FILE #32

Merged
merged 6 commits into from
Oct 25, 2021

Conversation

pimterry
Copy link
Contributor

Fixes #16

This includes a commit to extract file loading from the unix configuration. I've refactored and simplify that, which seemed to have some leftover complexity logic from partial loading, that was removed by #26. I've also updated the README, which referenced the old API that was replaced by #26.

The final commit is the actual change. I've had to add serial_tests on the tests here, because the env-var setting is global, so it breaks things when running tests in parallel. The tests use badssl.com (self-signed.badssl.com specifically) which is a site specifically for testing SSL client behaviour with various certificate scenarios.

I have only implemented SSL_CERT_FILE here, not SSL_CERT_DIR. There was some discussion about this at the start of #16, I think the conclusion was that it's much more complicated (see #9) and rarely worthwhile. Happy to discuss, but imo we should leave that as a future extension if/when somebody specifically requests it.

One very debatable point: this returns an error if the variable is set but points to a non-existent/unreadable/unparseable certificate file (rather than falling back to the existing platform logic). Is that the right decision? It makes it much easier to spot issues early if SSL_CERT_FILE was set incorrectly, but I imagine it might cause unexpected problems in some cases. What do you think?

If we're happy with that there's probably an argument for providing more specific error messages here at least, I can look into that if we're agreed that failing is the right choice.

This will be used shortly to load certs from an env var, on all
platforms.

This also simplifies the logic of unix's load_native_certs. Previously
this had leftover parts of an implementation for partial results, but it
was no longer used - first_error always took precendence.
Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the right direction, some style suggestions below.

Cargo.toml Show resolved Hide resolved
src/cert_env.rs Outdated Show resolved Hide resolved
src/cert_file.rs Outdated Show resolved Hide resolved
@djc
Copy link
Member

djc commented Oct 14, 2021

Also if you can make sure all files end with a trailing newline, that would be nice.

@pimterry
Copy link
Contributor Author

Newlines fixed

Copy link
Member

@ctz ctz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@djc djc merged commit 52c77e2 into rustls:main Oct 25, 2021
@djc
Copy link
Member

djc commented Oct 25, 2021

Thanks!

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.

Support SSL_CERT_FILE/SSL_CERT_DIR
3 participants