rust-lang / rust-lang/rustup

`client error (Connect): invalid peer certificate: Other(OtherError(NameConstraintViolation))` when using `rustls` backend

Open
#4,233 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
22h 40m
Merged PRs (30d)
46

Description

Verification
Problem

(This issue has been created at the request of @djc in this this comment)

Hello,

I've started running into an issue with rustup 1.28.0 + 1.28.1 since switching to the rustls backend. (Apologies for not noticing the CfT for testing sooner - I would have tried these changes in our environment sooner.)

For some context, I'm running rustup inside of a rather restrictive corporate environment and we have a mirror of Rust crates and toolchains (mirror created with Panamax) and we configure RUSTUP_DIST_SERVER and RUSTUP_UPDATE_ROOT to point to this mirror. Our crate/toolchain mirror is secured with a certificate issued from our own internal CA. When attempting to use rustup 1.28 with this mirror, I now see the error:

error sending request for url (https://rustmirror.ourcompany.com/dist/channel-rust-1.85.0.toml.sha256): client error (Connect): invalid peer certificate: Other(OtherError(NameConstraintViolation))

This CA hasn't caused any problems with rustup in the past and switching back an alternative backend (either by setting RUSTUP_USE_RUSTLS=0 or RUSTUP_USE_CURL=1 works perfectly fine. OpenSSL appears to verify the certificate used by the server correctly, and it seems to work fine with other TLS implementations as well (e.g. a dummy Golang or Java client that just tries to make an https connection works fine).

Our CA structure is something like this:

Root CA -> Issuing CA -> Server Cert (e.g. rustmirror.ourcompany.com)

The only name constraint that I can see is that our Root CA has a name constraint for C=CA so that all certs below the Root CA should have this constraint and I have verified that C=CA is part of the other certs in the chain. I will mention that I've now noticed that the leaf certificate has C=ca whereas the other certs in the chain are C=CA (note the case difference) - my understanding is that this shouldn't be problematic but I mention it for the sake of completeness.

If there's any other debugging steps that can be done on my side to provide more information I'm happy to try to do my best to help, but for now I'll be sticking with the Curl backend and would humbly request that it not be removed any time soon. 😅

Steps
  1. Use rustup >= 1.28.0 to download a toolchain from our internal toolchain mirror or to update rustup itself.
Possible Solution(s)

No response

Notes

No response

Rustup version
rustup 1.28.1 (f9edccde0 2025-03-05)
Installed toolchains
stable-x86_64-unknown-linux-gnu (active, default)
OS version
Arch Linux via WSL2 (5.15.167.4-microsoft-standard-WSL2)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with rustup 1.28.x, the rustls backend, and a mirror using the described Root CA → Issuing CA → Server Cert chain. Compare it with the working curl or OpenSSL path and investigate the NameConstraintViolation; done means the internal mirror connects through rustls without regressing certificate validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.