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-certificates

npm 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.pem

npm

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-wide

Poetry

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 and pip.conf

Without the certificates setting, a self-signed certificate makes Poetry report the hostname cannot be resolved by your DNS. The real cause shows with -vvv as CERTIFICATE_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
EcosystemClient setting
Maven~/.m2/settings.xml mirror: url = https://sfw.example.com/maven, mirrorOf = *
NuGetnuget.config package source: https://sfw.example.com/nuget/v3/index.json
Goexport 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 lodahs fails with E403
  • docker compose logs socket-firewall | grep SOCKET_DECISION on the firewall host shows the requests (needs SOCKET_IGNORE_LOG_LEVEL=warn, set in Stand up Socket Firewall for the first time)

Troubleshooting

SymptomFix
DEPTH_ZERO_SELF_SIGNED_CERT, UNABLE_TO_VERIFY_LEAF_SIGNATURE or SELF_SIGNED_CERT_IN_CHAINSet npm's cafile, or use a certificate from a trusted CA
404 on every package requestYou'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-environmentUse a venv
Installs still go to the public registryClear caches (npm cache clean --force, pip --no-cache-dir), and check for a project-level .npmrc or pip.conf overriding yours
📘

DNS override

DNS override protects the same package managers with no setting on the developer machine. See DNS override.


Did this page help you?