microsoft / microsoft/winappCli
`cert install` and `cert info` advertise CER support but only accept PFX
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.3k
- Forks
- 80
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 51
Description
Summary
The help text for cert install describes its argument as a certificate "(PFX or CER)", but the implementation only ever loads PKCS#12. Passing a .cer fails with a raw cryptography error rather than a useful message. cert info has the same defect.
Repro
> winapp cert generate --publisher "CN=Contoso" --export-cer
> winapp cert info devcert.cer
Result: exit code 1, Cryptography_Der_Invalid_Encoding.
Verified against the bundled 0.6.0 CLI and a 0.6.1-pr dev build.
Cause
CertificateService.InstallCertificate uses X509CertificateLoader.LoadPkcs12FromFile for both the already-installed check and the install itself, so a DER-encoded .cer can never load:
ExtractPublisherFromCertificate (same file, ~L383) does the same, which is why cert info fails identically.
Why it matters
--export-cer exists precisely so a public certificate can be handed to someone else to trust. That recipient's natural next step is winapp cert install <the .cer> — which the help text tells them to do, and which does not work. Today the .cer is only usable via certutil / Import-Certificate, so the export has no supported path back into the CLI.
Options
- Make it true — load with
X509CertificateLoader.LoadCertificateFromFilewhen the file isn't PKCS#12, and install the public certificate into the trust store. This is the behaviour the help text already promises and the one that makes--export-cerself-consistent. - Make the docs true — drop "or CER" from both help strings and fail a
.cerwith a clear message ("expected a PFX; to trust a .cer use …") instead of a DER decoding error.
Option 1 seems more useful, but either is better than the current mismatch.
Downstream note
The WinApp VS Code extension (microsoft/WinAppVSCE) offered .cer in its certificate file pickers on the strength of this help text; those filters have been narrowed to .pfx to match the actual behaviour. If option 1 lands we'd be happy to widen them again.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/winapp-CLI/WinApp.Cli/Services/CertificateService.cs, examining InstallCertificate and ExtractPublisherFromCertificate, then reproduce the failure with the cert generate and cert info commands. Resolve the documented PFX/CER behavior consistently for install and info, including a useful failure path if CER support is not added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100