uv/crates/uv-configuration/src
Charlie Marsh d86075fc1e
Add support for --trusted-host (#6591)
## Summary

This PR revives https://github.com/astral-sh/uv/pull/4944, which I think
was a good start towards adding `--trusted-host`. Last night, I tried to
add `--trusted-host` with a custom verifier, but we had to vendor a lot
of `reqwest` code and I eventually hit some private APIs. I'm not
confident that I can implement it correctly with that mechanism, and
since this is security, correctness is the priority.

So, instead, we now use two clients and multiplex between them.

Closes https://github.com/astral-sh/uv/issues/1339.

## Test Plan

Created self-signed certificate, and ran `python3 -m http.server --bind
127.0.0.1 4443 --directory . --certfile cert.pem --keyfile key.pem` from
the packse index directory.

Verified that `cargo run pip install
transitive-yanked-and-unyanked-dependency-a-0abad3b6 --index-url
https://127.0.0.1:8443/simple-html` failed with:

```
error: Request failed after 3 retries
  Caused by: error sending request for url (https://127.0.0.1:8443/simple-html/transitive-yanked-and-unyanked-dependency-a-0abad3b6/)
  Caused by: client error (Connect)
  Caused by: invalid peer certificate: Other(OtherError(CaUsedAsEndEntity))
```

Verified that `cargo run pip install
transitive-yanked-and-unyanked-dependency-a-0abad3b6 --index-url
'https://127.0.0.1:8443/simple-html' --trusted-host '127.0.0.1:8443'`
failed with the expected error (invalid resolution) and made valid
requests.

Verified that `cargo run pip install
transitive-yanked-and-unyanked-dependency-a-0abad3b6 --index-url
'https://127.0.0.1:8443/simple-html' --trusted-host '127.0.0.2' -n` also
failed.
2024-08-27 09:36:50 -04:00
..
authentication.rs Retain and respect settings in tool upgrades (#5937) 2024-08-09 18:21:49 +00:00
build_options.rs Remove --legacy-setup-py command-line argument (#4255) 2024-08-20 11:31:46 -05:00
concurrency.rs Add UV_CONCURRENT_INSTALLS variable in favor of RAYON_NUM_THREADS (#3646) 2024-05-17 23:12:37 -04:00
config_settings.rs Retain and respect settings in tool upgrades (#5937) 2024-08-09 18:21:49 +00:00
constraints.rs Remove uses of Option<MarkerTree> (#5978) 2024-08-10 13:23:29 -04:00
extras.rs Move extra specification into uv-configuration (#3897) 2024-05-29 04:49:57 +00:00
hash.rs Implement a --verify-hashes hash-checking mode (#4007) 2024-07-17 21:25:31 +00:00
install_options.rs refactor: use a struct for install options (#6561) 2024-08-27 05:38:16 -05:00
lib.rs Add support for --trusted-host (#6591) 2024-08-27 09:36:50 -04:00
name_specifiers.rs Add --no-build, --no-build-package, and binary variants (#4322) 2024-06-14 04:05:00 +00:00
overrides.rs Remove uses of Option<MarkerTree> (#5978) 2024-08-10 13:23:29 -04:00
package_options.rs Retain and respect settings in tool upgrades (#5937) 2024-08-09 18:21:49 +00:00
preview.rs Add preview mode and use for warning in uv run (#3192) 2024-04-22 15:41:15 -05:00
sources.rs Retain and respect settings in tool upgrades (#5937) 2024-08-09 18:21:49 +00:00
target_triple.rs Add 32-bit Windows target (#6252) 2024-08-20 14:06:25 +00:00
trusted_host.rs Add support for --trusted-host (#6591) 2024-08-27 09:36:50 -04:00