rustup installation fails in Windows Subsystem for Linux (WSL) when ZScaler intercepts HTTPS traffic because the proxy’s certificate is not trusted by the Linux environment. To resolve this, you must export the ZScaler root CA from your Windows browser and import it into WSL’s system trust store. This allows cURL to validate the Rust installer's connection securely without SSL errors.
Understanding the SSL Interception Issue
Corporate networks often use tools like ZScaler to inspect encrypted web traffic for security compliance. When you run wget or cURL inside WSL, these tools operate within a Linux kernel environment that does not automatically share the Windows certificate store. Consequently, the Linux-based cURL rejects the ZScaler proxy certificate as untrusted, resulting in an SSLError during the Rust installation process.
This issue is distinct from general WSL connectivity problems. For more information on broader network configuration challenges, see Troubleshooting SSH Connection Issues from External IP Address. Unlike standard internet connectivity, this specific error requires explicit certificate management within the Linux subsystem.
Exporting the ZScaler Root Certificate from Windows
The first step is obtaining the correct certificate file from your Windows host. You cannot simply copy any certificate; you need the root CA that signs ZScaler's intercept certificates.
- Open Microsoft Edge or Google Chrome on your Windows host.
- Navigate to any website served through ZScaler (e.g., rust-lang.org).
- Click the lock icon in the address bar and select "Certificate is valid" or view certificate details.
- In the certificate window, navigate to the Certification Path tab.
- Select the top-most entry in the hierarchy (usually labeled "Zscaler Root CA" or similar).
- Click "View Certificate" and then go to the Details tab.
- Click "Copy to File..." to launch the Certificate Export Wizard.
- Select "Base-64 encoded X.509 (.CER)" format.
- Save the file to a known location, such as
C:\Users\YourName\zscaler-root.cer.
Ensure you save the file with the .cer extension. DER format may cause parsing issues in some Linux tools, so Base-64 PEM format is preferred for compatibility with OpenSSL utilities.
Importing the Certificate into WSL Trust Store
Once the certificate is exported, you must move it into the WSL filesystem and add it to the system-wide trust store. This process varies slightly depending on whether you are using Ubuntu, Debian, or another distribution.
- Open PowerShell or Command Prompt on Windows.
- Launch your WSL distribution:
wsl -d Ubuntu(replace Ubuntu with your distro name). - Create a directory for custom certificates if it does not exist:
sudo mkdir -p /usr/local/share/ca-certificates/extra - Copy the certificate from the Windows file system. If you saved it to
C:\Users\YourName\zscaler-root.cer, access it via/mnt/c/Users/YourName/zscaler-root.cer. - Move the file to the extra folder:
sudo cp /mnt/c/Users/YourName/zscaler-root.cer /usr/local/share/ca-certificates/extra/zscaler-root.crt
Note the extension change from .cer to .crt. The update-ca-certificates utility expects .crt files in the extra subdirectory.
- Update the system trust store:
sudo update-ca-certificates - Verify the output includes "adding to trust store".
If you encounter permission denied errors, ensure you are using sudo. If the command hangs, check your network connection within WSL using ping 8.8.8.8. For deeper troubleshooting of WSL initialization, refer to Troubleshooting: Windows Subsystem for Linux (WSL) Installation Issues.
Configuring Curl and Rustup
After importing the certificate, you should be able to download the Rust installer. However, sometimes cURL needs explicit instruction to use the system store, especially if global proxies are configured.
Test the connection first:
curl https://sh.rustup.rs -v
If the verbose output shows successful certificate verification, proceed with the installation:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
If you still face issues, you may need to set the CURL_CA_BUNDLE environment variable explicitly pointing to the system bundle:
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
Add this line to your ~/.bashrc or ~/.zshrc to make it permanent. This ensures all future cURL requests respect the updated trust store.
Verifying the Fix
Run the Rust version command to confirm everything is working:
rustc --version
If this returns a version number, the SSL error is resolved. If you continue to experience network-related failures, consider checking if your corporate firewall blocks direct downloads. In such cases, you might need to configure cURL to use the corporate proxy settings explicitly via --proxy flags, ensuring the proxy itself trusts the ZScaler certificate chain.
Frequently Asked Questions
Why does my WSL terminal show 'certificate verify failed'?
This error occurs because the Linux environment lacks the root CA certificate issued by your corporate ZScaler proxy. Without this certificate in the system trust store, cURL cannot verify the identity of the server it is connecting to.
Can I use the same .cer file for all my WSL distributions?
Yes, the certificate file is universal. However, you must import it separately into each WSL distribution's trust store. Each instance of Ubuntu or Debian has its own independent certificate database.
What if I am using Debian instead of Ubuntu?
The steps are nearly identical. Use sudo apt-get install ca-certificates if the package is missing, and run sudo update-ca-certificates after copying the .crt file to /usr/local/share/ca-certificates/extra.
Does this fix apply to Git operations as well?
Yes, Git uses cURL or LibSSH2 under the hood. Once the certificate is in the system trust store, Git will also recognize the ZScaler proxy as trusted for cloning repositories over HTTPS.
How do I remove the certificate later?
To revert the change, delete the .crt file from /usr/local/share/ca-certificates/extra and run sudo update-ca-certificates --fresh. This rebuilds the trust store without the added certificate.