Skip to content

feat: add --cacert flag for custom CA verification - #24

Merged
paveg merged 1 commit into
mainfrom
feat/cacert-flag
Jul 18, 2026
Merged

paveg merged 1 commit into
mainfrom
feat/cacert-flag

Conversation

@paveg

@paveg paveg commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Add a --cacert <path> flag that uses a custom PEM file as the trusted root for TLS verification,
so servers with self-signed certificates can be load-tested with full verification instead of --insecure.
This builds on the trust API (@tls.TrustedRoot::CustomPemFile) introduced by the async 0.20 upgrade in #20.

Changes

  • Config.cacert : String? plus the --cacert option in argparse; all Config construction sites updated
  • Trust resolution extracted into a shared helper trust_from_config (worker package), reused by the worker loop and the --debug path in main.
    Precedence: --insecure wins over --cacert; otherwise CustomPemFile(path) when set, SystemRoot by default
  • parse_args split into a thin @env.args() wrapper and a testable parse_args_from(argv) core, enabling CLI parse tests
  • README flags table updated

Verification

  • TDD: new tests confirmed failing (unbound identifier / missing field) before implementation
  • Unit tests: trust precedence (insecure+cacert → NoVerification, cacert → CustomPemFile, neither → SystemRoot) and CLI parsing (flag populates Config.cacert, absent → None)
  • moon test --target native 271/271, moon test (wasm-gc) 195/195 after rebasing onto current main
  • Smoke test: a nonexistent PEM path fails gracefully through the existing client-construction error path (reported as an error result, no crash)

Note: no end-to-end test against a real self-signed TLS server is included;
certificate loading and validation are exercised by moonbitlang/async's own test suite.

🤖 Generated with Claude Code

Lets users load-test servers with self-signed certificates by trusting a
custom PEM file instead of disabling TLS verification with --insecure.
--insecure still wins when both are set. Extracts the shared
trust_from_config helper so worker and the --debug path stay in sync.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: dc11b34

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.81%. Comparing base (6b6fe77) to head (dc11b34).

Files with missing lines Patch % Lines
src/cmd/main/cli.mbt 50.00% 1 Missing ⚠️
src/cmd/main/main.mbt 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
+ Coverage   63.79%   70.81%   +7.02%     
==========================================
  Files          16       16              
  Lines         743      747       +4     
==========================================
+ Hits          474      529      +55     
+ Misses        269      218      -51     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paveg
paveg merged commit f869166 into main Jul 18, 2026
4 checks passed
@paveg
paveg deleted the feat/cacert-flag branch July 18, 2026 21:46
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.

2 participants