fix: copy AWF CA cert to chroot-accessible path for ssl-bump#1555
fix: copy AWF CA cert to chroot-accessible path for ssl-bump#1555
Conversation
When ssl-bump and chroot are both active, NODE_EXTRA_CA_CERTS points to /usr/local/share/ca-certificates/awf-ca.crt which is a Docker volume mount on the container's overlay filesystem. After chroot /host, this path is inaccessible, causing TLS failures (transaction-end-before-headers in Squid, EHOSTUNREACH in Claude Code after 10 retries). Fix: copy the CA cert to /host/tmp/awf-lib/awf-ca.crt before chroot activates (same pattern as one-shot-token.so and get-claude-key.sh), then update NODE_EXTRA_CA_CERTS to the chroot-relative path. Also set SSL_CERT_FILE and REQUESTS_CA_BUNDLE so non-Node.js tools (curl, git, Python requests, Ruby) trust the AWF CA in both chroot and non-chroot ssl-bump modes. Cleanup is handled by the existing /tmp/awf-lib removal in the EXIT trap. Fixes #1546 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
Fixes SSL-bump trust failures when running in --chroot mode by ensuring the AWF CA certificate is available at a chroot-accessible path and by exporting CA-related environment variables for common toolchains.
Changes:
- Export
SSL_CERT_FILEandREQUESTS_CA_BUNDLEalongsideNODE_EXTRA_CA_CERTSwhen SSL-bump is enabled (non-chroot path). - In chroot mode, copy the mounted AWF CA cert to
/host/tmp/awf-lib/awf-ca.crtand repoint CA env vars to/tmp/awf-lib/awf-ca.crt(chroot-relative). - Extend
/tmp/awf-libcleanup conditions to include CA-cert copying.
Comments suppressed due to low confidence (2)
containers/agent/entrypoint.sh:732
- Cleanup relies on CLEANUP_CMD being executed by an EXIT trap, but the chrooted command later does
trap '${CLEANUP_CMD}' EXITand then immediatelyexec capsh .... A successfulexecreplaces the shell process and prevents the EXIT trap from running, so /tmp/awf-lib (including the copied CA cert) and ${SCRIPT_FILE} may be left behind on the host filesystem. To make the cleanup reliable, avoidexecat that point or move the trap/cleanup into the command run by capsh (or into ${SCRIPT_FILE} itself).
# Clean up /tmp/awf-lib if anything was copied (one-shot-token, CA cert, key helper)
if [ -n "${ONE_SHOT_TOKEN_LIB}" ] || [ -n "${AWF_CA_CHROOT}" ]; then
CLEANUP_CMD="${CLEANUP_CMD}; rm -rf /tmp/awf-lib 2>/dev/null || true"
fi
containers/agent/entrypoint.sh:493
- After copying the CA cert, the script immediately exports NODE_EXTRA_CA_CERTS/SSL_CERT_FILE/REQUESTS_CA_BUNDLE. Consider verifying the destination file exists/readable (e.g.,
[ -f /host/tmp/awf-lib/awf-ca.crt ]) before exporting, similar to the one-shot-token copy, to avoid advertising a broken CA path if the copy is incomplete.
if cp /usr/local/share/ca-certificates/awf-ca.crt /host/tmp/awf-lib/awf-ca.crt 2>/dev/null; then
AWF_CA_CHROOT="/tmp/awf-lib/awf-ca.crt"
export NODE_EXTRA_CA_CERTS="$AWF_CA_CHROOT"
# SSL_CERT_FILE is respected by curl, git, Python requests, Ruby, and most
# OpenSSL-based tools. This ensures non-Node.js tools also trust the AWF CA.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
containers/agent/entrypoint.sh
Outdated
| if mkdir -p /host/tmp/awf-lib 2>/dev/null; then | ||
| if cp /usr/local/share/ca-certificates/awf-ca.crt /host/tmp/awf-lib/awf-ca.crt 2>/dev/null; then |
There was a problem hiding this comment.
The chroot CA-copy block silently ignores failures to create /host/tmp/awf-lib (mkdir). Consider logging a warning when mkdir fails so ssl-bump trust issues in chroot are easier to diagnose.
This issue also appears on line 489 of the same file.
Smoke Test Results✅ GitHub MCP — #1553 [WIP] Create daily token usage analysis workflow; #1552 [WIP] Fix NODE_EXTRA_CA_CERTS path issue after chroot for SSL bump Overall: PASS
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Verify destination file exists after copy ([ -f ] check) - Log warning when mkdir /host/tmp/awf-lib fails - Include CHROOT_KEY_HELPER in cleanup condition to prevent /tmp/awf-lib leak when only key helper was copied Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Smoke Test Results
Overall: PASS
|
|
Smoke test results — run 23866922726
Overall: PASS PR author:
|
|
Smoke Test Results
|
Smoke Test: GitHub Actions Services Connectivity
All checks passed. (
|
Chroot Version Comparison Results
Overall: ❌ FAILED — Python and Node.js versions differ between host and chroot environments. The chroot uses Ubuntu 22.04 system packages (Python 3.12.3, Node v20.20.1) while the host has newer versions installed via tool managers. Go matches because both use the same toolchain installation.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS Notes
|
Problem
When
--ssl-bumpand--chrootare both active,NODE_EXTRA_CA_CERTSpoints to/usr/local/share/ca-certificates/awf-ca.crt— a Docker volume mount on the container's overlay filesystem. Afterchroot /host, this path is inaccessible because it's not under the/hostmount tree.Symptom: Claude Code exhausts 10 API retries with
EHOSTUNREACH. Squid logs showtransaction-end-before-headerswithNONE_NONEdecisions because the dynamically-generated ssl-bump certificate (signed by the AWF CA) is rejected by Node.js.Root Cause
The CA cert is mounted into the container at
/usr/local/share/ca-certificates/awf-ca.crtbydocker-manager.ts. Theentrypoint.shsetsNODE_EXTRA_CA_CERTSto this path. But afterchroot /host, the filesystem root changes to the host mount, and the container-side path no longer exists.Solution
Apply the same copy pattern used for
one-shot-token.soandget-claude-key.sh: copy the CA cert to/host/tmp/awf-lib/before the chroot activates, then update env vars to the chroot-relative path/tmp/awf-lib/awf-ca.crt.Changes in
containers/agent/entrypoint.sh:Non-chroot ssl-bump (lines 104-119): Also set
SSL_CERT_FILEandREQUESTS_CA_BUNDLEso non-Node.js tools (curl, git, Python) trust the AWF CAChroot ssl-bump (new block after get-claude-key.sh copy): Copy CA cert to
/host/tmp/awf-lib/awf-ca.crtand updateNODE_EXTRA_CA_CERTS,SSL_CERT_FILE, andREQUESTS_CA_BUNDLEto the chroot-relative pathCleanup (line 726): Extended cleanup condition to also trigger when
AWF_CA_CHROOTis set (ensures/tmp/awf-libis cleaned up even if one-shot-token was not copied)Env vars set for ssl-bump:
NODE_EXTRA_CA_CERTSSSL_CERT_FILEREQUESTS_CA_BUNDLEVerification
The fix can be verified by running with
--ssl-bump --chrootand confirming:NODE_EXTRA_CA_CERTSresolves to an accessible path after chrootcurl https://allowed-domainsucceeds without certificate errorsEHOSTUNREACHFixes #1546
Upstream: github/gh-aw#23765