You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add devproxy cert export to write the root certificate to a file - #2091
↑ Full local suite passes, including end-to-end host tests for review counterexamples. ↑ stderr routing is triggered by the real System.CommandLine parse, not token guessing. ↓ Plugin options before cert export can still put plugin startup logs on stdout (documented, accepted). ↑ All CI checks pass on this head (3 OSes).
Adds devproxy cert export to write the public root certificate to a file, so CI scripts can trust Dev Proxy without a running instance, an API token, or openssl pkcs12.
Resolves the shared root certificate (creating it on first run, same as cert ensure) and writes only the public certificate — never the private key.
pem / crt: PEM-encoded (same content as GET /proxy/rootCertificate?format=crt); der: binary.
--format defaults to the --file extension (.crt, .der), otherwise pem.
--file defaults to dev-proxy-ca.<format> in the current directory; supports ~/path tokens, creates parent directories, and overwrites existing files.
Prints only the absolute path to stdout (CA=$(devproxy cert export)); --output json returns { path, format }.
Updates the CI/CD and CLI reference skill docs to use it instead of openssl.
Deviation from the issue: the issue proposes --output <file>, but --output is already the global, recursive text|json output-format option, so this uses --file.
Known limitation: plugin options placed before cert export (e.g. devproxy --mocks-file x cert export) can make plugin startup logs appear on stdout before the result, because plugins initialize before the command is parsed. Plugin options don't affect the export, so omit them; this is noted in the CI/CD skill reference.
Node.js/CI docs on learn.microsoft.com live in the docs repo and will be updated separately.
Adds 'devproxy cert export [--format pem|crt|der] [--file <path>]', which
writes the public root certificate (creating it if needed) without a
running instance and prints the written path. Uses --file instead of
--output because --output is the global text/json output-format option.
Updates CI/CD skill docs to use it instead of openssl.
Closesdotnet#2085
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The export can report success for an unpersisted, temporary root certificate that subsequent proxy runs replace, leaving clients unable to trust the proxy using the exported certificate.
…export
- Add CertificateAuthority.IsRootPersisted and fail cert export when a new
root couldn't be saved (it would change on the next run).
- Route all cert export diagnostics to stderr so stdout has only the path.
- Write --output json result directly to stdout, independent of log level.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Certificate export’s fixed-position command detection misses valid option placements, allowing CA-creation logs to contaminate the path or JSON output on stdout.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Route export logs correctly when options precede the command
DevProxy/Commands/DevProxyCommand.cs:130
This fixed-position check misses valid invocations with recursive options, such as devproxy cert --no-color export or devproxy --output json cert export. The export action still runs, but a newly created CA's Saved new root certificate... Information log goes to stdout, contaminating the captured path or JSON result. Detect the invoked command independently of option placement, and apply export's stderr routing before the IsRootCommand logging branch so prefixed options work too.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The export command can overwrite the stored CA certificate and private key with a public-only certificate, forcing root regeneration and invalidating existing trust.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Prevent certificate export from overwriting the stored CA
DevProxy/Commands/CertCommand.cs:178
With an absolute DEV_PROXY_CERT_PATH, devproxy cert export --file "$DEV_PROXY_CERT_PATH" passes the persistence check and then overwrites the stored root certificate and private key with a public-only certificate. The command reports success, but the next run cannot load the file as PKCS#12 and regenerates the root, invalidating existing trust and the exported certificate. Reject destinations that resolve to the CA's storage file before writing.
Detect certificate export commands after response-file expansion
DevProxy/Commands/DevProxyCommand.cs:132
With cert export in export.rsp, devproxy @export.rsp executes the export through response-file expansion, but this raw-argument scan leaves IsCertExportCommand false. On a fresh installation, the root-certificate save message therefore goes to stdout alongside the result, breaking command substitution and JSON consumers. Detect the command from expanded arguments before configuring logging so response-file invocations also send diagnostics to stderr.
Addressing the two previously-missed issues from the last Copilot review:
Export overwriting the stored CA: fixed. CertificateAuthority exposes RootCertificatePath, and cert export refuses to write when the destination is the same file. Matching is by normalized path, and by content when both files exist, so symlinked paths like /tmp → /private/tmp on macOS are also caught.
Response-file (@file.rsp) detection: won't fix. IsCertExportCommand uses the same raw-argv approach as the existing IsJwtCommand, IsConfigValidateCommand, and IsRootCommand, because logging is configured before System.CommandLine parses (and expands) arguments. Response-file invocations get a cosmetic log line on stdout at worst, the file is still written correctly, and it's not a realistic way to run a single short command. Fixing it properly means changing how every command is detected, which is out of scope here.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because response-file invocation can contaminate certificate-export stdout, while CI examples pin a version that lacks the export command.
Pinned CI examples: fixed. The pinned-v4.0.0 pipeline examples use openssl again. The "Trust the Root Certificate" section and CLI reference now document devproxy cert export as available in versions later than v4.0.0, with OpenSSL as the fallback.
Response files: unchanged. My reasoning is in the previous comment; this is the same limitation all the raw-argv Is*Command helpers have.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because response-file invocation of certificate export can mix creation diagnostics into stdout on fresh installations, breaking command substitution and JSON consumers.
Resolve CertCommandTests conflict by combining cert export tests with main's cert ensure tests and pass a temp CertificateAuthority to the updated CertCommand constructor.
Co-authored-by: Copilot App <[email protected]>
Resolve DevProxyCommand.cs conflict: keep the extracted CreateRootOptions
structure, register the new ValidateCommand, and treat 'validate' as a
built-in command name in cert export detection.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The command detector mistakes the plugin-option value cert for a command, routing a valid JWT invocation’s result to stderr and leaving stdout empty for scripts.
devproxy --mocks-file cert jwt create --scopes export was detected as
cert export, routing JWT output to stderr. Apply the unknown-option
value checks to tokens between cert and export too.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The command detector mistakes a mocks-file value named cert for the subcommand, causing first-run certificate diagnostics to pollute stdout and break valid export output.
devproxy --mocks-file cert cert export was rejected because the first
cert was taken as the command. When cert follows an unknown option and
the command check fails, retry treating it as the option's value.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because an unpublished blocking finding shows that mock generation can be mistaken for certificate export, suppressing plugin errors.
Environment: macOS 27.2.1, .NET SDK 10.0.103, OpenSSL 3.6.5. Source application/plugin builds passed with zero warnings/errors after locked restores. Isolated HOME, CFFIXED_USER_HOME, pre-created Library/Application Support, and unique DEV_PROXY_CERT_PATH; no system trust or proxy changes.
74 assertions passed; two assertions reproduced one PR-attributable diagnostic-suppression defect. This current-head retest supersedes my earlier functional approval. Automated suites were not rerun locally; current-head CI checks were inspected.
Scenario or test command
Expected
Actual
Result
Default PEM/CRT/DER exports; extension inference; explicit format override
Correct format, absolute path, matching public-only CA
All certificate parses and output contracts matched; no private key exported
PASS
Nested paths/spaces, home/app/data tokens, overwrite stale file and independent PFX copy
Exit 1 and actionable errors identifying invalid files
Head exited 1, wrote empty mocks, and printed nothing to either stdout or stderr
FAIL
Valid cert/export HTTP files: same command
Exit 0, generated mocks, confirmation diagnostic
Head generated two correct mocks but suppressed every progress/success message
FAIL
Both mock-generation reproductions on captured base in separately built clean checkout
Establish whether suppression predates PR
Base printed processing/confirmation messages and both invalid-file errors; identical inputs/options
PASS
Current-head CI
Automated validation passes
All 13 checks successful, including macOS/Linux/Windows tests, builds, smoke, CodeQL
PASS
Stop owned PID and cleanup
Do not affect concurrent testers; preserve source
stop --pid 44750 exit 0; process exit verified; owned fixture/logs and baseline worktree removed; source worktree clean
PASS
Requested changes
Preserve plugin-command diagnostics when arguments contain cert export
Requested change: Do not select certificate-export logging for actual plugin commands such as mocks from-http-responses. Distinguish the plugin command path and its positional arguments from unknown option values, or route export diagnostics without globally disabling plugin logs. Add command-level regression coverage preserving the repeated-cert and JWT fixes.
Expected: With invalid input, exit 1 and stderr containing Error processing file .../cert and .../export, including Invalid HTTP response format. With valid input, preserve normal progress and Generated mock responses saved to out.json.
Actual: The head returns the same exit codes and writes the same mocks as base, but stdout and stderr are both empty for the prefixed plugin command. Users receive no explanation for failure or confirmation of generation.
Reproduction: Configure MockResponsePlugin and GenericRandomErrorPlugin, set validateSchemas:false, installCert:false, noFirstRun:true, and use an owned persisted CA. In a fixture directory, write invalid HTTP response into two files named cert and export. Run devproxy --config-file /absolute/test-config.json --failure-rate 10 mocks from-http-responses cert export --mocks-file out.json. Observe exit 1 and empty stdout/stderr. Remove --failure-rate 10 to see the errors on the same head, or run the identical invocation on base 61346d968d73f38c94d3bcb7130f22c29f91171a, which prints both errors. Replacing the files with HTTP/1.1 200 OK\nContent-Type: application/json\n\n{"fixture":2091}\n reproduces the suppressed success/progress messages.
Request changes. Certificate-export scenarios and CI passed, but the plugin-command diagnostic regression is reproducible on the tested head and absent on the captured base. This assessment is functional testing, not a separate code review. No fixes, commits, pushes, or merges were made; cleanup is complete.
Restore CRLF line endings in DevProxyCommand.cs to match main. Pass the
proxy configuration to CreateRootOptions for main's CI-aware install-cert
validator, and use ordinal StartsWith for the new CA1307 rule.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Command detection misinterprets option values and mocks arguments as cert export, causing JWT JSON output to be routed to stderr and mocks completion or error messages to be suppressed.
Plugin options and commands made the token-based cert export detector
misread option values and plugin command arguments as `cert export`,
silencing diagnostics or moving structured results to stderr.
The command now switches console logging to stderr when cert export
actually runs (after System.CommandLine parsing with all plugin options).
The early check only recognizes invocations that use built-in options, so
it can no longer misclassify other commands. Adds unit and end-to-end
regression tests, and makes a WebSocket relay test independent of the
order in which the two relay directions are captured.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
No active review issues remain for the certificate export change.
No open issues 🎉
Review effort: Balanced
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pr-enhancementProduct features, behavior fixes, and usability or compatibility improvements
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
40324d0d2f908a1c1824dbe9c4d24e4d7d4115ee↑ stderr routing is triggered by the real System.CommandLine parse, not token guessing.
↓ Plugin options before
cert exportcan still put plugin startup logs on stdout (documented, accepted).↑ All CI checks pass on this head (3 OSes).
Adds
devproxy cert exportto write the public root certificate to a file, so CI scripts can trust Dev Proxy without a running instance, an API token, oropenssl pkcs12.cert ensure) and writes only the public certificate — never the private key.pem/crt: PEM-encoded (same content asGET /proxy/rootCertificate?format=crt);der: binary.--formatdefaults to the--fileextension (.crt,.der), otherwisepem.--filedefaults todev-proxy-ca.<format>in the current directory; supports~/path tokens, creates parent directories, and overwrites existing files.CA=$(devproxy cert export));--output jsonreturns{ path, format }.openssl.Deviation from the issue: the issue proposes
--output <file>, but--outputis already the global, recursivetext|jsonoutput-format option, so this uses--file.Known limitation: plugin options placed before
cert export(e.g.devproxy --mocks-file x cert export) can make plugin startup logs appear on stdout before the result, because plugins initialize before the command is parsed. Plugin options don't affect the export, so omit them; this is noted in the CI/CD skill reference.Node.js/CI docs on learn.microsoft.com live in the docs repo and will be updated separately.
Resolves #2085