Skip to content

openssl: Not using /etc/ #472492

Open
Open

Description

@497a

Nixpkgs version

  • Unstable (26.05)

Describe the bug

openssl does not use the config at /etc/ssl/openssl.cnf but instead uses a built in config. This is an issue as soon as one wants to change said config. Though it technically possible through the conf override, doing so triggers a mass rebuild that beyond anything that is reasonable or even feasible (for me it was 3000+ packages that take several tens of hours on 8 builders, plus several dependencies failing to build at all).

Steps to reproduce

~$ strace openssl list -providers 2>&1 | grep etc

access("/etc/ld-nix.so.preload", R_OK)  = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/61i74yjkj9p1qphfl7018ja4sdwkipx0-openssl-3.6.0/etc/ssl/openssl.cnf", O_RDONLY) = 3

Expected behaviour

Openssl should read /etc/ssl/openssl.cnf

Screenshots

No response

Relevant log output

Additional context

No response

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.18.1, NixOS, 26.05 (Yarara), 26.05.20251217.af84f9d
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Lix, like Nix) 2.93.3 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/void/.config/nix/nix.conf:/nix/store/lpf46bniz5m04p9w21rcnqdnp170hsqy-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/void/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/void/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/void/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/w7x0993gjpy31k5v5xklnqmd8q0br8h0-lix-2.93.3/share
  • nixpkgs: /nix/store/krhf9igjyi7h8c5mlddxd8fhwv1ljmzm-source

Notify maintainers

@thillux @ulrikstrid


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Activity

  1. added
    0.kind: bug
    on Dec 19, 2025
  2. IncredibleLaser commented on Dec 19, 2025

    @IncredibleLaser
    Contributor

    I haven't tried this yet, but it might be easier to do something like

    system.replaceDependencies.replacements = [ {oldDependency = pkgs.openssl; newDependency = pkgs.openssl.override { conf = ./your.conf; } } ];

    https://search.nixos.org/options?channel=unstable&query=replaceDependencies

  3. 497a commented on Dec 20, 2025

    @497a
    Author

    I haven't tried this yet, but it might be easier to do something like

    system.replaceDependencies.replacements = [ {oldDependency = pkgs.openssl; newDependency = pkgs.openssl.override { conf = ./your.conf; } } ];

    https://search.nixos.org/options?channel=unstable&query=replaceDependencies

    While this of course works, it is not quite a solution but rather a work around if the goal is to modify the global openssl config. Furthermore I don't think it is reasonable having to do that for every relevant package when there should be a much more straight forward option.

    Another plus of being able to use the config at /etc/ssl would be the possibility of introducing a nixos option for configuring openssl, the file format seems to be INI.

  4. IncredibleLaser commented on Dec 20, 2025

    @IncredibleLaser
    Contributor

    I haven't tried this yet, but it might be easier to do something like
    system.replaceDependencies.replacements = [ {oldDependency = pkgs.openssl; newDependency = pkgs.openssl.override { conf = ./your.conf; } } ];
    https://search.nixos.org/options?channel=unstable&query=replaceDependencies

    While this of course works, it is not quite a solution but rather a work around if the goal is to modify the global openssl config. Furthermore I don't think it is reasonable having to do that for every relevant package when there should be a much more straight forward option.

    This setting is system-wide, not per package.

  5. 497a commented on Dec 20, 2025

    @497a
    Author

    In that case I could surely try that but I would expect the same to happen. My other points still stand though; it's not a solution but rather a workaround.

  6. Atemu commented on Dec 20, 2025

    @Atemu
    Member

    replaceDependencies also uses IFD wich is not great in general and undesirable in many cases.

  7. Atemu commented on Dec 20, 2025

    @Atemu
    Member

    I think we should investigate:

    1. What happens when the file cannot be found or opened; whether it falls back to the default settings of the example config
    2. Whether there is a configure flag to set the config path to replace the current (IMHO) hack
  8. Atemu commented on Dec 20, 2025

    @Atemu
    Member
  9. thillux commented on Dec 20, 2025

    @thillux
    Contributor

    What are you trying to achieve with this global config? I'd like to understand your problem first. I also use another OpenSSL config, but only for a small amount of packages, where I'm totally ok with replacing the OpenSSL input with my overriden one and rebuilding them. A global /etc/ssl/openssl.cnf also does not work with e.g. different OpenSSL versions in parallel in the nix store, which should pick up different settings. I'd like to keep this config out of a global path if possible IMHO.

  10. Atemu commented on Dec 21, 2025

    @Atemu
    Member

    A global /etc/ssl/openssl.cnf also does not work with e.g. different OpenSSL versions in parallel in the nix store, which should pick up different settings.

    That's a good point.

    Though is it really the case that settings for a newer OpenSSL would break older ones (or vice versa)?

  11. marcin-serwin commented on Jan 17, 2026

    @marcin-serwin
    Contributor

    I'd like to keep this config out of a global path if possible IMHO.

    Needing to rebuild a package just to change its runtime config is an unusual convention. Generally, packages in nixpkgs respect the files in /etc and use modules to aid in configuration and reproducibility. The package is already not perfectly pure as it's patched to use the certificates from /etc.

    A global /etc/ssl/openssl.cnf also does not work with e.g. different OpenSSL versions in parallel in the nix store, which should pick up different settings.

    If that's the main concern then perhaps we could restrict only the legacy 1.1 and 3.0 versions and let the main one use the system-wide config?

  12. Atemu commented on Mar 4, 2026

    @Atemu
    Member

    Needing to rebuild a package just to change its runtime config is an unusual convention. Generally, packages in nixpkgs respect the files in /etc and use modules to aid in configuration and reproducibility. The package is already not perfectly pure as it's patched to use the certificates from /etc.

    The trouble here is that openssl isn't a regular package that you explicitly configure yourself an instance of to run on your system but rather a library you implicitly use by using (practically) any program that does crypto.

    A file in /etc therefore becomes global configuration state for nearly any application you will run and we should avoid such global state wherever possible.

    The cert bundle is a standardised format with a very small set of possible variances. The openssl config file is most certainly not.

    If that's the main concern then perhaps we could restrict only the legacy 1.1 and 3.0 versions and let the main one use the system-wide config?

    The trouble is that, should there be a openssl 4.0 that breaks config file ABI, apps compiled against our 3.0 will break.


    Could anyone with a use-case for openssl config please try whether the env var I found can be used to control it? That would solve this issue as env vars are easy enough to scope for any use-case.

  13. andrewzah commented on May 26, 2026

    @andrewzah
    Contributor

    @Atemu

    Could anyone with a use-case for openssl config please try whether the env var I found can be used to control it? That would solve this issue as env vars are easy enough to scope for any use-case.

    Yes, OPENSSL_CONF=/path/to/custom/openssl.cnf is the standard way of doing this. Confirm with man openssl-env and man config.

    # from `man config`
    OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
    
    # from `man openssl-env`
          OPENSSL_CONF, OPENSSL_CONF_INCLUDE
               Specifies  the  path  to  a  configuration  file  and the directory for included files.  See
               config(5).
    

    Pointing to a global config would only have downsides, in addition to the "rebuilding the world" problem that comes with changing the openssl derivation.

  14. Atemu commented on May 27, 2026

    @Atemu
    Member

    @497a could you test whether using an env var works for you? :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions