-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
crypto: support --use-system-ca on non-Windows and non-macOS #57009
Conversation
Review requested:
|
4a711b4
to
c455c04
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57009 +/- ##
==========================================
- Coverage 89.10% 89.09% -0.02%
==========================================
Files 665 665
Lines 193203 193245 +42
Branches 37220 37223 +3
==========================================
+ Hits 172158 172167 +9
- Misses 13771 13807 +36
+ Partials 7274 7271 -3
|
c455c04
to
2c44065
Compare
c78e1bb
to
0d6c04a
Compare
On other platforms, load from the OpenSSL default certificate file and diretory. This is different from --use-openssl-ca in that it caches the certificates on first load, instead of always reading from disk every time a new root store is needed. When used together with the statically-linked OpenSSL, the default configuration usually leads to this behavior: - If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise load from /etc/ssl/cert.pem - If SSL_CERT_DIR is used, load from all the files under SSL_CERT_DIR. Otherwise, load from all the files under /etc/ssl/certs
0d6c04a
to
891de46
Compare
20cff99
to
822e288
Compare
822e288
to
803ce60
Compare
|
||
uv_fs_t stats_req; | ||
auto cleanup_stats = | ||
OnScopeLeave([&stats_req]() { uv_fs_req_cleanup(&stats_req); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, just thinking out loud... it would be nice if we had smart pointer type wrappers for these so we could simplify this kind of code.
Looks like there's a minor linting issue but otherwise LGTM |
Fixed the linter error (TIL "UNIX" is a trademark but "Unix" isnt?!) 🤯 |
Landed in 579fc67 |
On other platforms, load from the OpenSSL default certificate file and diretory. This is different from --use-openssl-ca in that it caches the certificates on first load, instead of always reading from disk every time a new root store is needed. When used together with the statically-linked OpenSSL, the default configuration usually leads to this behavior: - If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise load from /etc/ssl/cert.pem - If SSL_CERT_DIR is used, load from all the files under SSL_CERT_DIR. Otherwise, load from all the files under /etc/ssl/certs PR-URL: #57009 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
crypto: support --use-system-ca on non-Windows and non-macOS
On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.
When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:
load from /etc/ssl/cert.pem
SSL_CERT_DIR. Otherwise, load from all the files under
/etc/ssl/certs
I've only checked Ubuntu and RHEL so far. It may be worth checking whether this works on other popular distributions - from what I can tell, though, it seems the hard-coded configurations always leads to default locations under
/etc/ssl/
, which seems to be a location that most Linux distros would either use or link to anyway - for example, Ubuntu symlinks all the managed certificates to files under/etc/ssl/certs
, while RHEL 9 just bundles all managed certificates to/etc/ssl/certs/ca-bundle.crt
, so the current approach would usually just work.If this somehow turns out to be sufficient, we can come back adding specific fallbacks for other systems similar to what go does which is basically listing all the directories that are known to be used for this purpose - but from what I can tell this can be slow and lead to duplicates since they might get symlinked to each other, so ideally if
X509_get_default_cert_dir()
andX509_get_default_cert_file()
works on a platform, it's better not to look further to avoid unnecessary costs.There is also the question of whether we should use NSS shared DB, like what Chrome does, but since most command line tools rely on the directory/file-based system-wide storage instead (like go listed above, and e.g. every rust tool using the rustls-native-certs crate), and it seems to be losing the point if we statically link NSS, I didn't go with this route. In any case it seems various distros already consolidates the NSS shared DB somehow into these default locations when they manage their certificate stores, or at least NSS DB can be loaded via environment variable overrides, so the current approach looks good enough.