Skip to content

[RFC] libssl abstraction, default to libressl instead of openssl#10468

Closed
fpletz wants to merge 2 commits intoNixOS:masterfrom
mayflower:feature/libssl-libressl
Closed

[RFC] libssl abstraction, default to libressl instead of openssl#10468
fpletz wants to merge 2 commits intoNixOS:masterfrom
mayflower:feature/libssl-libressl

Conversation

@fpletz
Copy link
Copy Markdown
Member

@fpletz fpletz commented Oct 18, 2015

This is a RFC to add a generic libssl attribute to depend on an openssl compatible libssl implementation. Also, this changes the default libssl implementation to libressl.

Some software doesn't work yet with libressl, so there are some hardcoded dependencies on openssl where I stumbled on problems, but not all packages were tested. My laptop and some service VMs are working flawlessly. This is a work in progress.

Currently, libssl also includes libcrypto and the openssl utility (both included in libressl) but this could also be split out if needed.

I'd like some feedback if this change is welcome or if you prefer to add this in another way.

Side note: The libressl folks are working on a new TLS API called libtls, thus the choice to name the old API libssl (which is also the actual name of the library in question), which is already available in libressl today: http://www.openbsd.org/papers/libtls-fsec-2015/

@globin globin force-pushed the feature/libssl-libressl branch 3 times, most recently from 011af85 to 2cb428f Compare October 19, 2015 05:21
@peti
Copy link
Copy Markdown
Member

peti commented Oct 19, 2015

Why is libresslpreferable to openssl?

@abbradar
Copy link
Copy Markdown
Member

@peti Personally I would prefer LibreSSL because their aim is to clean up the code in OpenSSL and make it at least somewhat maintainable, which I, having unfortunately spent some time looking at the original code, can only welcome.
See also (very informal) http://www.openbsd.org/papers/bsdcan14-libressl/mgp00001.html -- it's very biased towards LibreSSL of course, but it shows main pain points.

@domenkozar
Copy link
Copy Markdown
Member

libressl got a security advisory a few days ago (doesn't affect openssl) http://seclists.org/oss-sec/2015/q4/87

@globin
Copy link
Copy Markdown
Member

globin commented Oct 19, 2015

Generally openssl has had much more CVEs than openssl since libressl forking off and libressl aim to clean up a lot of the old cruft from which is totally worthless now.

See https://wiki.freebsd.org/LibreSSL for a list of vulnerabilities.

@fpletz fpletz force-pushed the feature/libssl-libressl branch from 2cb428f to b2f3d4b Compare October 19, 2015 11:34
@globin globin force-pushed the feature/libssl-libressl branch from b2f3d4b to b99cb44 Compare October 19, 2015 11:44
@peti
Copy link
Copy Markdown
Member

peti commented Oct 19, 2015

How do other distributions handle this? Does anyone else prefer libressl over openssl?

@abbradar
Copy link
Copy Markdown
Member

I think no, apart from OpenBSD but they don't qualify as a Linux distribution ^_^.

@vcunat
Copy link
Copy Markdown
Member

vcunat commented Oct 19, 2015

I can't even find the package in major distros, but I suppose it would be nontrivial for them to have a different version of libssl along with the default. Void Linux sounds as a Linux distribution, though https://en.wikipedia.org/wiki/LibreSSL#Adoption

@abbradar
Copy link
Copy Markdown
Member

I also remember several Arch Linux packages in AUR and guides for replacing OpenSSL with LibreSSL on it; the biggest problem is, as @vcunat said, a big difficulty in having two libssl versions -- some packages use OpenSSL APIs that LibreSSL has discontinued. This is a problem that Nix solves elegantly.

@globin
Copy link
Copy Markdown
Member

globin commented Oct 19, 2015

@abbradar up to libressl 2.2* there should be no problems with discontinued APIs, only 2.3 removes all SSLv3 code which I have seen break 2 packages so far, one fixed on master (#10463), the other open in #10465

@globin
Copy link
Copy Markdown
Member

globin commented Oct 19, 2015

I personally would prefer using libressl 2.2.4 as default for now in NixOS as that is the latest stable release, 2.3 being the current snapshot releases.

@zimbatm
Copy link
Copy Markdown
Member

zimbatm commented Nov 22, 2015

Might I suggest to first only introduce pkgs.libssl as an abstraction for "a libssl-compatible library" ? Reaching consensus for this might be quicker than mixing both items. This branch touches a lot of packages and is likely expensive to maintain. I believe that there is also more that two choices: gnutls and boringssl also come to mind (although boringssl seem like a pain to bootstrap).

In regards to pkgs.libss. Is aliasing a good-enough solution or do we need a mechanism to fallback to openssl for well-known broken libraries ?
Also related, how do we prevent package authors to link openssl instead of libssl when creating new packages ?

@globin
Copy link
Copy Markdown
Member

globin commented Nov 22, 2015

👍

@Mathnerd314
Copy link
Copy Markdown
Contributor

Void Linux sounds as a Linux distribution, though

Also see Gentoo's overlay.

How do we prevent package authors to link openssl instead of libssl when creating new packages ?

This seems impossible; openssl is what is in all the documentation etc., NixOS is not powerful enough to make everyone switch to using libssl instead.

Here's how I would allow libressl:

openssl-official = <current openssl>
openssl = if config.useLibressl or false then libressl else openssl-official;

openssl is a generic[1] term for both the official OpenSSL library and its forks, and openssl-official can be used for packages that don't work with libressl, like so:

mypkg = callPackage ../development/mypkg { openssl = openssl-official; };

[1] Generic terms are generic, not the first user owns them -- Kay Sievers

@nbp nbp added 0.kind: enhancement Add something new or improve an existing system. 1.severity: mass-rebuild 9.needs: changelog This PR needs a changelog entry 8.has: clean-up This PR removes packages or removes other cruft 8.has: module (update) This PR changes an existing module in `nixos/` and removed 8.has: module (update) This PR changes an existing module in `nixos/` labels Nov 22, 2015
@zimbatm
Copy link
Copy Markdown
Member

zimbatm commented Nov 23, 2015

This seems impossible; openssl is what is in all the documentation etc., NixOS is not powerful enough to make everyone switch to using libssl instead.

We can always solve the problem with another layer of indirection :p Maybe pkgs.libssl would become a function that takes a white and a black list and returns the right derivation. Then all SSL libraries are removed from the top-level and then the only way to access them is trough that function.

That being said, I don't think that most people will want to switch libraries. After all you need the recompile half of the programs in the system and don't benefit from the hydra builds anymore.

I like your idea of taking openssl as the generic name, this is the library I would look for when developing packages and not libssl. Then I would read the all-packages.nix and understand what's going on from a comment. Just having openssl = libressl is probably enough as it can be changed with overrides and is not likely to be frequent.

@vcunat
Copy link
Copy Markdown
Member

vcunat commented Nov 23, 2015

I like your idea of taking openssl as the generic name

Me too. The switch shouldn't involve touching hundreds of expressions. That tends to create merge interactions, e.g. with the closure-size branch. And there's not just libssl but libcrypto in there, too.

The line openssl = if ..... is probably unnecessary, as packageOverrides seems perfectly suited for such changes.

@lucabrunox
Copy link
Copy Markdown
Contributor

Indeed. I don't see a reason for this change, packageOverrides is perfectly enough.

Also for the discussion and a friendly reminder, that libressl and all other alternatives have seen less vulnerabilities because they are much less used than openssl.

@globin
Copy link
Copy Markdown
Member

globin commented Dec 13, 2015

We have stopped using this ourselves and changed to an approach overriding openssl with libressl_2_3 with the help of #11673 and #11653.

Then one can either set openssl_1_0_1 explicitly on packages that need ABI compatibility or patching software that relies on obsolete libssl code (#11674)

@fpletz
Copy link
Copy Markdown
Member Author

fpletz commented Dec 13, 2015

Okay, thanks for all the feedback. We will move forward by keeping the openssl attribute name for generic openssl API compatible implementations.

@fpletz fpletz closed this Dec 13, 2015
@nbp nbp mentioned this pull request Feb 26, 2017
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: enhancement Add something new or improve an existing system. 8.has: clean-up This PR removes packages or removes other cruft 9.needs: changelog This PR needs a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants