Skip to content

Commit 587d434

Browse files
committed
test(signatures): add buildChain test for self-signed ECDSA cert
1 parent 5ba4524 commit 587d434

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/signatures/signing.integration.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,30 @@ describe("signing integration", () => {
564564
const pdfStr = new TextDecoder().decode(bytes);
565565
expect(pdfStr).toContain("/SubFilter /adbe.pkcs7.detached");
566566
});
567+
568+
it("handles buildChain with self-signed ECDSA cert", async () => {
569+
const p12Bytes = await loadFixture("certificates", P12_FILES.ecdsaP256);
570+
571+
// Self-signed cert has no AIA URLs, so buildChain should gracefully handle this
572+
const signer = await P12Signer.create(p12Bytes, "test123", { buildChain: true });
573+
574+
expect(signer.certificate).toBeInstanceOf(Uint8Array);
575+
expect(signer.certificateChain).toHaveLength(0); // Self-signed has no chain
576+
577+
// Should still sign successfully
578+
const pdfBytes = await loadFixture("basic", "rot0.pdf");
579+
const pdf = await PDF.load(pdfBytes);
580+
581+
const { bytes, warnings } = await pdf.sign({
582+
signer,
583+
reason: "Self-signed ECDSA with buildChain",
584+
});
585+
586+
expect(warnings).toHaveLength(0);
587+
expect(bytes.length).toBeGreaterThan(pdfBytes.length);
588+
589+
await saveTestOutput("signatures/signed-ecdsa-p256-buildchain.pdf", bytes);
590+
});
567591
});
568592

569593
describe("error handling", () => {

0 commit comments

Comments
 (0)