Repository navigation
libressl: use the host CA bundle like openssl - #576513
Conversation
|
Targeting nixpkgs master sounds OK to me at this moment. (very many binaries are still missing in there) |
| # The default OPENSSLDIR is the relative path "etc/ssl", so libcrypto | ||
| # would look for its default CA file relative to the current directory. | ||
| "-DOPENSSLDIR=${placeholder "out"}/etc/ssl" |
There was a problem hiding this comment.
Shouldn't this follow the same semantics as the OpenSSL build? It is, after all, supposed to be the compatibility layer with OpenSSL.
See the various use-etc-ssl-certs.patch under pkgs/development/libraries/openssl.
Additionally, using that patch implies that, for any follow-up, the host system's mitigations for the cert bundle will naturally apply. And additionally-additionally, in the far future, using older (but newer than today) builds of libressl will also benefit from the system's up-to-date bundle.
cc @ruuda (maintainer).
There was a problem hiding this comment.
I am not familiar enough with the OpenSSL build; in my projects where I use the LibreSSL package, I use Nix only to build an image and then I take the certificate bundle from the host.
How do you propose to change it? I would prefer to avoid patches as much as possible.
There was a problem hiding this comment.
Good idea. I fixed the PR to match OpenSSL's approach.
|
It may also be questionable how It should, at least, be consistent. It's kinda bad if sometimes it's under the ambient |
ruuda
left a comment
There was a problem hiding this comment.
It looks okay to me. @samueldr-at-cyberus, if you have a suggestion to improve it further, could it be done as a follow-up, or do you think anything is wrong with the current version?
b61c27e to
e4123f4
Compare
| # so that libressl follows CA updates of the host like openssl does. | ||
| hostCaFile = | ||
| if stdenv.hostPlatform.isDarwin then | ||
| "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt" |
There was a problem hiding this comment.
hopefully we can unify both at some point...
OPENSSLDIR was the relative path "etc/ssl". Thus libcrypto (openssl CLI, SSL_CTX_set_default_verify_paths) looked for "etc/ssl/cert.pem" relative to the current directory, and libtls used the cacert of the package set. Set OPENSSLDIR to $out/etc/ssl. Point the default CA file of libcrypto (X509_CERT_FILE) and libtls (TLS_DEFAULT_CA_FILE) to the path of openssl's use-etc-ssl-certs patches: /etc/ssl/certs/ca-certificates.crt, or the bundle of the default profile on Darwin. A CA update of the host now applies without a rebuild. Remove the vendored $out/etc/ssl/cert.pem. Assisted-by: Claude Code (claude-opus-5)
e4123f4 to
f28e4b6
Compare
|
Removing the I think it does make sense to default to a path in (I will be away for a few days until Monday, I am fine with either solution so feel free to merge either way, because there is some time pressure on this one.) |
|
I'm generally in favor of having a global system-wide CA store. My only concern with this is on how it will interfere with potential sandboxes. For the Nix build sandbox it is probably not a big deal because it runs without internet access and TLS certificates signed by canonical CAs in unit tests are rare. |
|
I noticed libressl isn't patched to support NIX_SSL_CERT_FILE / SSL_CERT_FILE yet, which is the fallback that we need for the sandbox scenario. This is what Nix relies on if for example we want to use openssl to fetch from the FODs. |
LibreSSL reads neither variable: libcrypto uses X509_get_default_cert_file() and libtls the compiled-in TLS_DEFAULT_CA_FILE. Check NIX_SSL_CERT_FILE, then SSL_CERT_FILE, before the default in both, like openssl's nix-ssl-cert-file.patch. Setuid programs ignore the variables. In the build sandbox /etc/ssl does not exist and the cacert setup hook sets NIX_SSL_CERT_FILE, so this keeps libressl usable there. Assisted-by: Claude Code (claude-opus-5)
ruuda
left a comment
There was a problem hiding this comment.
The if ((file = nix_cert_file_env()) == NULL) assignment inside a condition is a bit cryptic for my taste, I would have put it on a separate line, but it works and we should merge this sooner rather than later, so LGTM.
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin staging-26.05
git worktree add -d .worktree/backport-576513-to-staging-26.05 origin/staging-26.05
cd .worktree/backport-576513-to-staging-26.05
git switch --create backport-576513-to-staging-26.05
git cherry-pick -x f28e4b68bf174604ceda72d63bfdf2453e31396b 9dfc9b9542c6160fa43bbd7717ebd7fc21ab797c |
OPENSSLDIR was the relative path "etc/ssl". Thus libcrypto (openssl CLI, SSL_CTX_set_default_verify_paths) looked for "etc/ssl/cert.pem" relative to the current directory, and the vendored $out/etc/ssl/cert.pem was not used.
Set OPENSSLDIR to $out/etc/ssl and replace the vendored cert.pem with a symlink to the cacert bundle, like TLS_DEFAULT_CA_FILE for libtls.
Related to: #576485
Related to: #576541
Assisted-by: Claude Code (claude-opus-5)
Things done
./result/bin/.nixpkgs-reviewon this PR. See nixpkgs-review usage.passthru.tests.