Configure registry: dev
Point a developer machine's package managers at the firewall.
Configure each package manager to use the firewall instead of the public registry. Some package managers require the firewall's CA file when the certificate is not from a trusted CA. Do this per machine, or push the same files with MDM.
Before you start: sfw.example.com resolves to the firewall (DNS record, or /etc/hosts for testing).
Trust the certificate
Skip this if the firewall uses a certificate from a CA your machines already trust. Otherwise copy ssl/fullchain.pem from the firewall host to the developer machine as sfw-ca.pem.
# macOS system trust
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain sfw-ca.pem
# Debian and Ubuntu system trust
sudo cp sfw-ca.pem /usr/local/share/ca-certificates/sfw-ca.crt && sudo update-ca-certificatesnpm runs on Node.js, which uses its own CA list and does not read the system store by default.
npm config set cafile /path/to/sfw-ca.pemnpm
npm config set registry https://sfw.example.com/npm/Writes registry=https://sfw.example.com/npm/ to ~/.npmrc. pnpm and Yarn 1 read the same .npmrc. Yarn 2+ uses npmRegistryServer in .yarnrc.yml instead.
pip
pip config set global.index-url https://sfw.example.com/pypi/simple/
pip config set global.cert /path/to/sfw-ca.pem # only if the CA isn't trusted system-widePoetry
poetry source add --priority=primary socket-fw https://sfw.example.com/pypi/simple/
poetry config certificates.socket-fw.cert /path/to/sfw-ca.pem # only if the CA isn't publicly trusted
Poetry ignores the system store andpip.confWithout the
certificatessetting, a self-signed certificate makes Poetry reportthe hostname cannot be resolved by your DNS. The real cause shows with-vvvasCERTIFICATE_VERIFY_FAILED.
Other ecosystems
Add the routes you need under path_routing.routes in socket.yml, then docker compose up -d --force-recreate:
- path: /maven
upstream: https://repo1.maven.org/maven2
registry: maven
- path: /nuget
upstream: https://api.nuget.org
registry: nuget
- path: /go
upstream: https://proxy.golang.org
registry: go| Ecosystem | Client setting |
|---|---|
| Maven | ~/.m2/settings.xml mirror: url = https://sfw.example.com/maven, mirrorOf = * |
| NuGet | nuget.config package source: https://sfw.example.com/nuget/v3/index.json |
| Go | export GOPROXY=https://sfw.example.com/go |
Maven runs on the JVM, which has its own truststore. On Debian and Ubuntu, the ca-certificates-java package hooks into update-ca-certificates and updates the Java cacerts keystore. Where ca-certificates-java is installed, the update-ca-certificates step from Trust the certificate already added the CA to the JVM. Anywhere else, import the CA with the command that follows.
sudo keytool -importcert -noprompt -alias sfw -file sfw-ca.pem -cacerts -storepass changeit # JDK 9+Go still fetches checksums from sum.golang.org directly. On networks with locked-down egress, allow that host or set GOSUMDB / GONOSUMDB.
Verify
npm config get registry
npm cache clean --force
npm install lodash # succeeds
npm install lodahs # 403, blocked# Current Debian/Ubuntu block system-wide pip installs (PEP 668), so use a venv
# On a stock Debian/Ubuntu host, first: sudo apt install python3-venv
python3 -m venv .venv && . .venv/bin/activate
pip install --no-cache-dir requests # succeeds- Clean installs succeed through the firewall
-
npm install lodahsfails with E403 -
docker compose logs socket-firewall | grep SOCKET_DECISIONon the firewall host shows the requests (needsSOCKET_IGNORE_LOG_LEVEL=warn, set in Stand up Socket Firewall for the first time)
Troubleshooting
| Symptom | Fix |
|---|---|
DEPTH_ZERO_SELF_SIGNED_CERT, UNABLE_TO_VERIFY_LEAF_SIGNATURE or SELF_SIGNED_CERT_IN_CHAIN | Set npm's cafile, or use a certificate from a trusted CA |
| 404 on every package request | You're reaching the firewall by IP or another hostname. Use sfw.example.com |
| Poetry: "hostname cannot be resolved" | Certificate not trusted. Set poetry config certificates.socket-fw.cert |
pip: externally-managed-environment | Use a venv |
| Installs still go to the public registry | Clear caches (npm cache clean --force, pip --no-cache-dir), and check for a project-level .npmrc or pip.conf overriding yours |
DNS overrideDNS override protects the same package managers with no setting on the developer machine. See DNS override.
Updated 13 days ago