-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
SSL_CERT_FILE causes SSL certificate errors with other tools #921
Comments
Can you print the value of |
|
I just hit this again with the trivial case |
The cause seems to be that the nix CA bundle requires a curl with OpenSSL support, which (current) builtin versions don’t have.
I worked around this using more Homebrew:
That version works, but Homebrew won’t use it unless I also patch I assume a similar workaround can work by installing curl from nix, but I haven’t checked yet. |
This seems kind of bad and off-putting for new OSX users. Is anyone looking into it? |
Might be good to start using tags in this repo and let more of us tag issues. Would be good for those of us wanting to improve the darwin experience to track down darwin-specific pain. |
I just wasted ~30 min on this bug; please fix! |
I also hit this today. 😭 Any
I finally tracked it down to the
Here are some other issues which appear to be related to (or a duplicate of) this:
Unsetting |
@layus FYI - thanks! 😄 |
So if I understand correctly, Nix CA requires curl with OpenSSL built, but the default curl on OSX doesn't have that. What are the options here? I don't have a darwin platform, but would love to help this getting fixed. |
Thanks @domenkozar for helping out. 👍 I suspect now the problem might be that the cacerts file I had on my machine at the time I installed nix was invalid... I installed curl via homebrew and get the same problem when using the cacerts file that nix was pointing to, and I suspect the brew version of curl should work with OpenSSL as it has it as a dependency. Here is a demo of the problem I have when using the a cacerts file: First I download the latest version of the file in pem format:
Next I try to use it with a curl command:
Now I use curl without specifying a cacert file, and problem goes away:
And now, to show the format of the cacert file:
The curl version I am using above is I'm wondering now if the problem is that I shouldn't use this file, but some adapted version of it, and maybe when I installed nix I referred to (an older version of) this file, and the mistake was made then (I don't remember where that file came from, if it was shipped with nix, or if I had my own version etc). Thanks @domenkozar for any ideas you might have! |
Note, the version that my nix installation was pointing to was a bit older (see below - from Nov 9 last year). In my demonstration above, I was just trying with the latest version of the file, in case that might have fixed things (which it didn't). Also when I was using brew to install things originally, or using curl directly, I was not explicitly specifying
|
It has OpenSSL as an optional dependency, which is used if you install it with You can check whether your version uses OpenSSL by checking the output of
|
Nix ships a curl package that trusts /etc/ssl/certs/ca-bundle.crt by default. This is not always available on non NixOS distros. To make nix-only installs working on other distros, we make the nix setup script export SSL_CERT_FILE to some existing cert bundle to ensure that the curl package shipped and used by Nix works properly. (Otherwise, nix cannot download derivations.) I i understand this bug, the issue is that this behavior breaks curl builds without openssl support, right ? Now, I have a few questions:
|
|
https://docwhat.org/el-capitan-and-the-evils-of-openssl/ has it all explained. Apparently, setting SSL_CERT_FILE makes SecureTransport fall back to the (very old) openssl shipped by MacOS. This old version is incompatible with current certificates. This is a hard problem, because this is not a problem only with curl. SSL_CERT_FILE is required by every package using openssl. |
@kballard, @petemoore you should really contact apple about this. Their version of openssl is very old, and setting SSL_CERT_FILE to a recent bundle makes it fail... But this is also something I am not willing to investigate. I do not want to spend time understanding and fixing closed source software. |
I see two solutions:
|
If I understand the Homebrew formula correctly, this can be done by passing |
@mkhl Thanks, I'll give that a try. |
I would trust the second option, but be aware that it may break applications relying on the default trust store of openssl, as openssl will no more find the trust store in |
Hm, curl segfaults when built with darwinssl:
|
@copumpkin @pikajude Could the segfault above be caused by the mixing of the system Security framework and the Nixpkgs CoreFoundation framework?
|
Indeed
fixes the segfault. But is there a proper solution for this? |
I've raised Bug 27968953 "SecureTransport problem causes /usr/bin/curl to fail if env var SSL_CERT_FILE is set, or --cacert option is passed" with the Apple Bug Reporter, against product "OS X". The content of the bug is essentially the same as for the github curl/curl issue referenced above. |
Yeah, that's it. I'd be reluctant to introduce more impurity into nix itself, but we could probably make it work if you think the pros outweigh the cons here.
|
I've run into this issue the last several times I've given nix-on-darwin a try and it's really discouraging. I decided to do some research and found this issue which exactly described my experience. As nix is just the package manager here, it seems odd that it wouldn't integrate with the system trust store. I know it's unfortunate that macOS is using such an old openssl package, but it would really help me if I could try out nix alongside my existing homebrew setup which is broken any time I activate nix (preventing me from adding it to my zshrc). |
ping @edolstra |
@layus are you sure that works?
|
Here is the 1.11.7 candidate, testing on non-NixOS systems (especially OS X) welcome: http://hydra.nixos.org/eval/1335054 |
@edolstra I tried Edit: I guess
|
I can not reproduce this bug on
|
Waiting on https://travis-ci.org/domenkozar/test-nix-1-11-7/builds/204213775 as well |
@edolstra nix-env fails to work:
|
@domenkozar Is my input still needed ? Do you mean that apple fixed their curl with 10.12.x ? |
@layus no, I think Nix is currently broken with this fix (see below). But this fix is not needed on Sierra.
|
travis-ci confirms my findings for last three OSX versions: https://travis-ci.org/domenkozar/test-nix-1-11-7/builds/204213775 |
@domenkozar #1247 unbreaks this for me |
I can confirm that, at least as of macOS 10.12.3, |
@domenkozar weird results...
Edit: Of course, you install only the osx executable, it cannot work on linux. |
Don't mind Linux, just OSX. |
@domenkozar Right, but |
Thanks, fixed |
Travis build succeeded, I'll now build a few things on OSX to verify more broadly. |
@edolstra looks good to me on OSX, curl and git work from nix and from OSX itself. |
$NIX_SSL_CERT_FILE overrides $SSL_CERT_FILE, which in turn overrides the default CA path (/etc/ssl/certs/ca-certificates.crt). This allows Nix to set a CA path without interfering with other packages (such as Homebrew). See NixOS/nix#921. (cherry picked from commit 942dbf8)
I think I might be facing a related problem. I'm using a recently updated macOS Nix installation with Nix-installed version of Mercurial (
I'm using macOS 10.12.6 with What should I try to diagnose, debug, and fix or workaround? |
@xpe: follow-up in NixOS/nixpkgs#27928 |
I tried to install something with Homebrew today (a package that is out of date on Nix) and it failed with the following error:
Digging into this, it's trying to download a file using curl that, after redirects, ends up fetching a URL like
https://akamai.bintray.com/5c/5ce4e36ed803d7ee2863b8a84b2123fb29f34e02e7c2f908284bb24408f94a65?__gda__=exp=1464730847~hmac=bfe122e8b6bcbf8d01952ab997861ac1fed2434aceccc74cf5c356ad107a1481&response-content-disposition=attachment%3Bfilename%3D%22git-lfs-1.2.0.el_capitan.bottle.tar.gz%22&response-content-type=application%2Fgzip
(I assume this URL is not permanent)
The fetch for this resource is what triggers the certificate verification failure. Unsetting
$SSL_CERT_FILE
fixes the issue. My assumption here is that the root certificate for that server isn't included in Nix's ca-bundle.crt, though I don't know why that would be.This is with Nix 1.11.2 on OS X 10.11.5.
The text was updated successfully, but these errors were encountered: