Add cert info command, --export-cer flag, and --json output for cert commands#305
Add cert info command, --export-cer flag, and --json output for cert commands#305
Conversation
Build Metrics ReportBinary Sizes
Test Results✅ 323 passed, 6 skipped out of 329 tests in 52.0s (+24 tests, -7.6s vs. baseline) CLI Startup Time32ms median (x64, Updated 2026-02-27 21:17:45 UTC · commit |
There was a problem hiding this comment.
Pull request overview
This PR enhances the cert command group with new functionality for programmatic certificate management. It introduces a cert info subcommand for inspecting certificate details, adds a --export-cer flag for exporting public keys separately, and implements --json output mode for machine-readable responses across cert commands. Additionally, it fixes a bug where --output only accepted file names, not absolute paths.
Changes:
- New
cert infocommand displays certificate metadata (subject, issuer, thumbprint, validity, private key status) --export-cerflag oncert generateexports a.cerfile (public key only) alongside the.pfx--jsonoutput mode forcert generateandcert infowith consistent error handling via JSON- Bug fix:
--outputoption now accepts absolute and relative paths (changedAcceptLegalFileNamesOnly()toAcceptLegalFilePathsOnly())
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/winapp-CLI/WinApp.Cli/Services/StatusService.cs | Adds ExecuteQuietlyAsync method to suppress console output for JSON mode execution |
| src/winapp-CLI/WinApp.Cli/Services/IStatusService.cs | Interface definition for ExecuteQuietlyAsync |
| src/winapp-CLI/WinApp.Cli/Services/CertificateService.cs | Implements .cer export logic and adds exportCer parameter to certificate generation methods |
| src/winapp-CLI/WinApp.Cli/Services/ICertificateService.cs | Adds exportCer parameter to interface methods |
| src/winapp-CLI/WinApp.Cli/Program.cs | Suppresses logging in JSON mode by setting LogLevel.None and skips first-run notice |
| src/winapp-CLI/WinApp.Cli/Models/JsonOutputModels.cs | New file defining JSON output models with source-generated serialization |
| src/winapp-CLI/WinApp.Cli/Commands/WinAppRootCommand.cs | Defines global --json option for commands to opt into |
| src/winapp-CLI/WinApp.Cli/Commands/CertCommand.cs | Registers new CertInfoCommand as subcommand |
| src/winapp-CLI/WinApp.Cli/Commands/CertInfoCommand.cs | New command implementation for displaying certificate details |
| src/winapp-CLI/WinApp.Cli/Commands/CertGenerateCommand.cs | Adds --export-cer and --json support, fixes path validation bug |
| src/winapp-CLI/WinApp.Cli/Helpers/HostBuilderExtensions.cs | Registers CertInfoCommand handler in DI container |
| src/winapp-CLI/WinApp.Cli.Tests/CertInfoCommandTests.cs | Comprehensive tests for new cert info command covering parsing, output, and error cases |
| src/winapp-CLI/WinApp.Cli.Tests/CertGenerateCommandTests.cs | New tests for path validation, --export-cer, and --json functionality |
| src/winapp-CLI/WinApp.Cli.Tests/SignCommandTests.cs | Updates parameter name for clarity after signature change |
| docs/llm-context.md | Documents new command and options |
| docs/cli-schema.json | Updates CLI schema with new command and options |
Improves the
certcommand group with a new subcommand, a public key export flag, and structured JSON output for programmatic consumption.Changes
New:
cert infocommandDisplays certificate details from a PFX file — subject, issuer, thumbprint, serial number, validity dates, and private key status. Useful for verifying a certificate matches your manifest before signing.
New:
--export-cerflag oncert generateExports a
.cerfile (public key only) alongside the.pfx. Useful for distributing the public certificate separately for trust installation.New:
--jsonoutput on cert commandsBoth
cert generateandcert infosupport--jsonfor machine-readable output. When--jsonis specified:{"error": "..."}) instead of writing to stderr--jsonreject it with a parse errorBug fix:
--outputnow accepts absolute pathsChanged
AcceptLegalFileNamesOnly()toAcceptLegalFilePathsOnly()socert generate --output C:\certs\dev.pfxworks correctly.Type of Change
Checklist