feat(09-05): implement convertCert + wire POST /convert (GREEN)

- Add FileResponse interface and FORMAT_MIME map to service
- Implement convertCert: parses any input format (PEM/DER/PFX/P7B) via
  same logic as parseCert; serializes to pem/der/p7b targetFormat
- DER output uses bytesToHex→Buffer.from(hex,'hex') to avoid utf-8
  corruption (Pitfall 1 / T-09-06)
- P7B output: pkcs7.createSignedData + pem.encode (PEM-wrapped PKCS7)
- Wrap all forge ops in try/catch → BadRequestException (T-09-01)
- Controller: add @Body('pemText') + reject when neither file nor pemText
- Fix: re-add NotImplementedException import for mergeCerts stub
- All 23 API cert-manager tests green (including 4 new convertCert)
This commit is contained in:
2026-07-02 07:37:41 +02:00
parent 37db58b816
commit 59694642dd
3 changed files with 153 additions and 8 deletions
@@ -397,7 +397,8 @@ describe('convertCert', () => {
// Decode base64 P7B (PEM-wrapped PKCS7) and verify at least 1 cert enclosed
const p7bContent = Buffer.from(result.content as string, 'base64').toString('utf-8');
const p7 = forge.pkcs7.messageFromPem(p7bContent);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const p7 = forge.pkcs7.messageFromPem(p7bContent) as any;
expect((p7.certificates as forge.pki.Certificate[]).length).toBeGreaterThanOrEqual(1);
});