承接 lufox11/pdf-sign-validator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lufox11/pdf-sign-validator

Composer 安装命令:

composer require lufox11/pdf-sign-validator

包简介

A simple wrapper to validate a PDF signature against a public key.

README 文档

README

PDF Sign Validator is a simple wrapper to validate a PDF signature against a public key.
After spending an entire day looking for a similar solution I gave up and ended up building a solution by myself with the help of my best friend, John Stack Overflow.
This is nothing more than just a wrapper of real cryptographic functions from Sop\ANS1 and Sop\X509 repositories.

Installation

Just require this package in your project using Composer:

composer require lufox11/pdf-sign-validator

Usage

Methods you may'd like to use:

signCount: Returns the amount of signatures found in file.
signIsValid: Validates that the file signature corresponds to the issuer's root PEM certificate.
certIsValid: Validates that the subject certificate was issued by the issuer certificate.
signMatchSubject: Validates that the certificate (extracted from the signature) match the subject's PEM certificate.
infoFromPDF: Reads an attached signature to a PDF file and returns the info inside.
infoFromPEM: Reads a certificate in PEM format and returns the info inside.

A real use case (Argentina):

  1. Sign a PDF file through Firmar.gob.ar and download the file (signed.pdf).
  2. Download the issuer's root certificate (issuer.cer).
  3. Download your public certificate (subject.cer).
use LufoX11\PdfSignValidator\PdfSignValidator;

/**
 * signed.pdf: Path to the signed PDF file.
 * issuer.cer: Path to the public key file (RSA PUBLIC KEY) of the issuer.
 * subject.cer: Path to the public key file (RSA PUBLIC KEY) of the subject.
 */

$amountOfSignatures = PdfSignValidator::signCount('signed.pdf');
$certificateIsValid = PdfSignValidator::certIsValid('subject.cer', 'issuer.cer');
$certificateData = PdfSignValidator::infoFromPEM('certificate.cer');
$certificateData = PdfSignValidator::infoFromPDF('signed.pdf');

// Single signature in PDF file
$signatureIsValid = PdfSignValidator::signIsValid('signed.pdf', 'issuer.cer');
$certificateMatchSubject = PdfSignValidator::signMatchSubject('signed.pdf', 'subject.cer');

// Multiple signatures in PDF file
// You can specify the signature to work with in dot notation
$signatureIsValid = PdfSignValidator::signIsValid('signed.pdf', 'issuer.cer', [ 'subject.common_name' => 'Lionel Messi' ]);
$certificateMatchSubject = PdfSignValidator::signMatchSubject('signed.pdf', 'subject.cer', [ 'issuer.common_name' => 'Magnus Carlsen' ]);

License

This project is licensed under the MIT License.

统计信息

  • 总下载量: 307
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固