Skip to content

PAdES 디지털 서명

Pro — Commercial License Required
PAdES B-T, B-LT, B-LTA 서명 수준은 Pro 패키지가 필요합니다.

TCPDF-Next Pro는 CertificateInfo, DigitalSigner, ByteRangeCalculator, SignatureAppearance를 사용하여 전체 PAdES 파이프라인(ETSI EN 319 142)을 구현합니다.

서명 수준

수준Enum 값추가되는 내용
B-BSignatureLevel::PAdES_B_B서명 인증서가 포함된 CMS 서명
B-TSignatureLevel::PAdES_B_TRFC 3161 서명 타임스탬프
B-LTSignatureLevel::PAdES_B_LTDSS를 통한 해지 데이터 (OCSP + CRL)
B-LTASignatureLevel::PAdES_B_LTA무기한 유효성을 위한 문서 타임스탬프

CertificateInfo

PEM 또는 PKCS#12 파일에서 X.509 인증서와 개인 키를 로드하고 파싱합니다.

php
use Yeeefang\TcpdfNext\Pro\Security\Signature\CertificateInfo;

// PEM 파일에서
$cert = CertificateInfo::fromPem('/certs/signing.pem', '/certs/signing.key', 'pw');
$cert->chain(['/certs/intermediate.pem', '/certs/root.pem']);

// PKCS#12에서 (체인 자동 추출)
$cert = CertificateInfo::fromPkcs12('/certs/signing.p12', 'p12-password');

// 인증서 상세 정보 확인
echo $cert->subjectCN();        // "John Doe"
echo $cert->issuerCN();         // "Acme Intermediate CA"
echo $cert->validFrom();        // DateTimeImmutable
echo $cert->ocspResponderUrl(); // "https://ocsp.acme.com"

DigitalSigner

CMS/PKCS#7 서명 컨테이너를 생성하고 타임스탬프 및 LTV 임베딩을 조율합니다.

php
use Yeeefang\TcpdfNext\Core\Document;
use Yeeefang\TcpdfNext\Pro\Security\Signature\DigitalSigner;
use Yeeefang\TcpdfNext\Pro\Security\Timestamp\TsaClient;
use Yeeefang\TcpdfNext\Contracts\Enums\SignatureLevel;

$pdf  = Document::create()->addPage()->text('Contract document.');
$cert = CertificateInfo::fromPkcs12('/certs/signer.p12', 'pw');
$tsa  = new TsaClient('https://tsa.example.com/timestamp');

$signer = new DigitalSigner($cert);
$signer->level(SignatureLevel::PAdES_B_LTA);
$signer->timestampAuthority($tsa);
$signer->reason('Document approval');
$signer->location('Taipei, Taiwan');

$signer->sign($pdf);
$pdf->save('/output/signed.pdf');

B-LT 및 B-LTA 수준에서는 LtvManager가 내부적으로 호출되어 OCSP 응답과 CRL을 가져오고 DSS 딕셔너리를 구성합니다.

ByteRangeCalculator

서명 플레이스홀더를 관리하고 바이트 범위를 계산합니다. DigitalSigner에 의해 내부적으로 처리되며, 직접 사용은 고급 시나리오를 위한 것입니다.

SignatureAppearance

페이지에서 서명의 시각적 표현을 제어합니다. 서명은 기본적으로 보이지 않습니다.

php
use Yeeefang\TcpdfNext\Pro\Security\Signature\SignatureAppearance;

$appearance = SignatureAppearance::create()
    ->page(1)
    ->position(x: 20.0, y: 250.0, width: 80.0, height: 30.0)
    ->text("Digitally signed by John Doe\nDate: 2026-02-16")
    ->image('/images/handwritten-signature.png')
    ->imagePosition('left')  // 'left', 'right', 'top', 'bottom', 'background'
    ->fontSize(8);

$signer->appearance($appearance);
$signer->sign($pdf);

완전한 B-LTA 예제

php
use Yeeefang\TcpdfNext\Core\Document;
use Yeeefang\TcpdfNext\Pro\Security\Signature\{DigitalSigner, CertificateInfo, SignatureAppearance};
use Yeeefang\TcpdfNext\Pro\Security\Timestamp\TsaClient;
use Yeeefang\TcpdfNext\Contracts\Enums\SignatureLevel;

$pdf = Document::create()
    ->addPage()
    ->font('Helvetica', size: 14, style: 'B')
    ->text('Purchase Agreement')
    ->font('Helvetica', size: 11)
    ->text('This agreement is entered into on February 16, 2026...');

$cert = CertificateInfo::fromPkcs12('/certs/legal.p12', 'passphrase');
$tsa  = new TsaClient('https://tsa.example.com/timestamp');

$signer = new DigitalSigner($cert);
$signer->level(SignatureLevel::PAdES_B_LTA);
$signer->timestampAuthority($tsa);
$signer->appearance(
    SignatureAppearance::create()
        ->page(1)
        ->position(x: 20.0, y: 250.0, width: 80.0, height: 25.0)
        ->text("Signed by Legal Dept.\n2026-02-16")
);
$signer->reason('Purchase agreement execution');
$signer->location('Taipei, Taiwan');

$signer->sign($pdf);
$pdf->save('/contracts/purchase-agreement-signed.pdf');

다음 단계

LGPL-3.0-or-later 라이선스로 배포됩니다.