Skip to content
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

Can't npins init because of certifcates #110

Open
gabrielhdt opened this issue Jan 27, 2025 · 3 comments
Open

Can't npins init because of certifcates #110

gabrielhdt opened this issue Jan 27, 2025 · 3 comments

Comments

@gabrielhdt
Copy link

The problem

Running npins init returns

[INFO ] Welcome to npins!
[INFO ] Creating `npins` directory
[INFO ] Writing default.nix
[INFO ] Writing initial sources.json with nixpkgs entry (need to fetch latest commit first)
Error: Failed to fetch initial nixpkgs entry

Caused by:
    0: error sending request for url (https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz): error trying to connect: invalid peer certificate: UnknownIssuer
    1: error trying to connect: invalid peer certificate: UnknownIssuer
    2: invalid peer certificate: UnknownIssuer

Expected behaviour

Doing other internet requests work, such as curl -L https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz > /dev/null, so I would expect npins to work as well. If there's a variable or a parameter to set, I would expect the program to indicate that here.

Environment

  • Nix multi user install (2.24.11)
  • Debian trixie on WSL2
  • Using custom SSL certificates
@piegamesde
Copy link
Collaborator

Npins does nothing fancy but a simple HTTP GET request. Given that you are using custom certificates, the most plausible explanation for the difference in behavior is that curl uses a different certificate store. Npins uses the rustls library for SSL, maybe the upstream documentation can tell which lookup chain for CA stores it uses and how to modify it.

@gabrielhdt
Copy link
Author

Shouldn't it be the client code that sets the appropriate root certificate store ? I see in the "Getting started" section of the documentation [1]

let root_store = rustls::RootCertStore::from_iter(
    webpki_roots::TLS_SERVER_ROOTS
        .iter()
        .cloned(),
);

so it seems to me there should be a call to that method somewhere that could be looking for the machine-wide certificates (or some other one) rather than the certificates of Mozilla.

Note that I'm no expert in network programming so I may be completely wrong.

[1] https://docs.rs/rustls/latest/rustls/?search=certificate#getting-started

@gabrielhdt
Copy link
Author

Aha ! I see there's a library called rustls-platform-verifier whose purpose seems to be to solve that issue in particular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants