Skip to content

feat: CA certificate support for corporate SSL inspection - #62

Merged
alanbem merged 2 commits into
mainfrom
feat/ca-cert-support
Mar 20, 2026
Merged

feat: CA certificate support for corporate SSL inspection#62
alanbem merged 2 commits into
mainfrom
feat/ca-cert-support

Conversation

@alanbem

@alanbem alanbem commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds CA_CERT config variable (.dclaude file) and DCLAUDE_CA_CERT env var for corporate environments with SSL inspection proxies
  • Sets NODE_EXTRA_CA_CERTS and SSL_CERT_FILE inside the container so Claude Code, npm, curl, and Python all trust the corporate CA
  • Resolves relative paths (from config file dir or working dir) and validates the cert is within the mounted directory tree

Usage

# .dclaude config file
CA_CERT=multitude-ca.pem

or

DCLAUDE_CA_CERT=./multitude-ca.pem dclaude

Test plan

  • DCLAUDE_CA_CERT=./some-cert.pem dclaude sets NODE_EXTRA_CA_CERTS and SSL_CERT_FILE inside container
  • CA_CERT=cert.pem in .dclaude config resolves relative to config file directory
  • Warning shown if cert file not found
  • Warning shown if cert is outside mounted directory
  • No changes to Docker image required — script-only change

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added custom CA certificate support for corporate SSL inspection. Users can set it via DCLAUDE_CA_CERT (env) or CA_CERT in .dclaude.
    • Relative paths are resolved to absolute; valid certs are injected into launched containers so apps use the certificate.
  • Documentation

    • Updated docs and examples to show new configuration options and usage.
  • Behavior

    • Missing or out-of-tree certs produce warnings and are not injected.

Adds CA_CERT config variable (.dclaude) and DCLAUDE_CA_CERT env var
to configure a custom CA certificate for environments with corporate
SSL inspection proxies. Sets NODE_EXTRA_CA_CERTS and SSL_CERT_FILE
inside the container, resolves relative paths, and validates the cert
is within the mounted directory tree.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6701833f-a405-4481-ab2a-2ab5cdf77110

📥 Commits

Reviewing files that changed from the base of the PR and between 953e6e3 and 6b1c391.

📒 Files selected for processing (1)
  • dclaude
✅ Files skipped from review due to trivial changes (1)
  • dclaude

📝 Walkthrough

Walkthrough

Adds support for a corporate CA certificate via a new CA_CERT .dclaude config variable and DCLAUDE_CA_CERT environment variable, with path resolution, validation, debug output, and conditional injection of NODE_EXTRA_CA_CERTS / SSL_CERT_FILE into Docker container args.

Changes

Cohort / File(s) Summary
Documentation
CLAUDE.md, README.md
Documented new CA_CERT (config) and DCLAUDE_CA_CERT (env) variables, added sample CA_CERT=certs/corporate-ca.pem and details about relative vs absolute path resolution.
Runtime / CLI
dclaude
Parsed CA_CERT from config when env var unset; resolved relative paths against config dir; canonicalized remaining relative env paths to absolute; added debug output for CA_CERT; validated file existence and containment under MOUNT_ROOT; conditionally appended NODE_EXTRA_CA_CERTS and SSL_CERT_FILE to Docker args or emitted warnings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConfigFile
    participant dclaude
    participant FS as FileSystem
    participant Docker

    User->>dclaude: start (env + optional .dclaude)
    dclaude->>ConfigFile: load_config_file()
    ConfigFile-->>dclaude: CA_CERT (relative or abs) or unset
    dclaude->>FS: resolve relative CA_CERT (realpath vs PWD fallback)
    FS-->>dclaude: absolute_path or missing
    dclaude->>dclaude: validate existence and MOUNT_ROOT containment
    alt valid and within MOUNT_ROOT
        dclaude->>Docker: add env NODE_EXTRA_CA_CERTS, SSL_CERT_FILE
        Docker-->>dclaude: container args assembled
    else missing or outside MOUNT_ROOT
        dclaude-->>User: emit warning (no container env added)
    end
    dclaude->>Docker: run container (with or without cert env)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hop through configs, nibble paths with care,

CA_CERT in paw, I make certificates fair.
Docker wears the cert like a tidy hat,
Secure little tunnels — click, clack, and that’s that. 🥕🔐

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding CA certificate support for corporate SSL inspection. It accurately reflects the primary purpose of the changeset across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ca-cert-support
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
dclaude (2)

170-174: Silent failure when realpath fails may confuse users.

If the user provides a relative path that doesn't exist (e.g., DCLAUDE_CA_CERT=./missing.pem), realpath fails and DCLAUDE_CA_CERT becomes empty due to || true. The later validation at line 1938 checks [[ ! -f "$CA_CERT" ]], but an empty CA_CERT passes this check silently (since [[ -n "$CA_CERT" ]] is the outer condition).

Consider preserving the original path so the "not found" warning is more helpful:

🔧 Suggested improvement
 # Resolve CA_CERT relative paths (env var: relative to PWD, config file: already resolved)
 if [[ -n "${DCLAUDE_CA_CERT:-}" && "${DCLAUDE_CA_CERT}" != /* ]]; then
-    DCLAUDE_CA_CERT=$(realpath "$DCLAUDE_CA_CERT" 2>/dev/null) || true
+    DCLAUDE_CA_CERT=$(realpath "$DCLAUDE_CA_CERT" 2>/dev/null) || DCLAUDE_CA_CERT="$PWD/$DCLAUDE_CA_CERT"
 fi

This preserves the intended path for the "not found" warning rather than clearing it entirely.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dclaude` around lines 170 - 174, The current block uses realpath on
DCLAUDE_CA_CERT but swallows failures with "|| true", which clears the variable
and hides the original path; change the logic so that realpath output is only
assigned to DCLAUDE_CA_CERT when realpath succeeds and otherwise leave
DCLAUDE_CA_CERT unchanged (preserving the user-provided path) so the later
CA_CERT existence check ([[ ! -f "$CA_CERT" ]]) can emit a helpful "not found"
warning; specifically, call realpath and check its exit status (or capture its
output into a temp var and assign only on success) when resolving
DCLAUDE_CA_CERT before exporting readonly CA_CERT.

1935-1950: Path prefix check has a subtle edge case.

The check [[ "$CA_CERT" != "$MOUNT_ROOT"* ]] correctly validates that the cert is under the mount root. However, it would incorrectly pass for paths like /home/user-other/cert.pem when MOUNT_ROOT=/home/user (since the glob matches the prefix).

A more robust check would ensure a path separator:

🛡️ More precise path containment check
-        elif [[ "$CA_CERT" != "$MOUNT_ROOT"* ]]; then
+        elif [[ "$CA_CERT" != "$MOUNT_ROOT"/* && "$CA_CERT" != "$MOUNT_ROOT" ]]; then

This ensures the certificate path is either exactly the mount root (unlikely for a file) or is under it with a path separator. That said, the current implementation is low-risk since accidental matches would require very specific naming coincidences.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dclaude` around lines 1935 - 1950, The prefix check for CA_CERT vs MOUNT_ROOT
can false-positive (e.g., /home/user-other when MOUNT_ROOT=/home/user); update
the containment logic in the CA certificate handling block to canonicalize both
paths (use realpath -m or readlink -f fallback) and then check that canonical
CA_CERT is equal to the canonical MOUNT_ROOT or starts with the canonical
MOUNT_ROOT plus a trailing slash; adjust the condition around the
CA_CERT/MOUNT_ROOT check (the block that currently uses [[ "$CA_CERT" !=
"$MOUNT_ROOT"* ]]) and keep adding NODE_EXTRA_CA_CERTS/SSL_CERT_FILE to
DOCKER_ARGS only when the containment check passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@dclaude`:
- Around line 170-174: The current block uses realpath on DCLAUDE_CA_CERT but
swallows failures with "|| true", which clears the variable and hides the
original path; change the logic so that realpath output is only assigned to
DCLAUDE_CA_CERT when realpath succeeds and otherwise leave DCLAUDE_CA_CERT
unchanged (preserving the user-provided path) so the later CA_CERT existence
check ([[ ! -f "$CA_CERT" ]]) can emit a helpful "not found" warning;
specifically, call realpath and check its exit status (or capture its output
into a temp var and assign only on success) when resolving DCLAUDE_CA_CERT
before exporting readonly CA_CERT.
- Around line 1935-1950: The prefix check for CA_CERT vs MOUNT_ROOT can
false-positive (e.g., /home/user-other when MOUNT_ROOT=/home/user); update the
containment logic in the CA certificate handling block to canonicalize both
paths (use realpath -m or readlink -f fallback) and then check that canonical
CA_CERT is equal to the canonical MOUNT_ROOT or starts with the canonical
MOUNT_ROOT plus a trailing slash; adjust the condition around the
CA_CERT/MOUNT_ROOT check (the block that currently uses [[ "$CA_CERT" !=
"$MOUNT_ROOT"* ]]) and keep adding NODE_EXTRA_CA_CERTS/SSL_CERT_FILE to
DOCKER_ARGS only when the containment check passes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9226d1c-f1d0-40e8-8ecd-c343dfb7ecd9

📥 Commits

Reviewing files that changed from the base of the PR and between f810dec and 953e6e3.

📒 Files selected for processing (3)
  • CLAUDE.md
  • README.md
  • dclaude

Ensures the user-provided path is kept for the "not found" warning
instead of silently clearing the variable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alanbem
alanbem merged commit 5c59c5c into main Mar 20, 2026
10 checks passed
@alanbem
alanbem deleted the feat/ca-cert-support branch March 20, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant