定制 setasign/setapdf-signer-x509-pdo-collection 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

setasign/setapdf-signer-x509-pdo-collection

Composer 安装命令:

composer require setasign/setapdf-signer-x509-pdo-collection

包简介

A X509\CollectionInterface implementation that uses PDO under the hood.

README 文档

README

An example X509\CollectionInterface implementation that uses PDO under the hood.

During the development two additional interfaces were implemented in SetaPDF and used in this project to get the best performance: X509\Collection\FindBySubjectKeyIdentifierInterface and X509\Collection\FindByKeyHashInterface.

This implementation shows how you can use a database as a source of e.g. trusted certificates for the ValidationRelatedInfo\Collector class.

For testing we use the certificate of the EUTL, Swiss Trust List and AATL. The trust lists are resolved by the setasign/trust-list-fetcher project.

Please make sure, that you implement your own update mechanism to keep the list up-to-date!

The database table structure

The implementation is technically independent to a database backend. It only requires a table with following columns, types and indexes:

Column Type Index / PK Info
tlVersion varchar(400) PK (tlVersion + digest) A trust list version identifiaction
digest char(20) PK (tlVersion + digest) The hash (SHA-1) of the certificate
keyHash char(20) Index The hash (SHA-1) of the public key
subject varchar(400) Index Longest subject in the EUTL is actually 274 bytes long.
issuer varchar(400) Index Longest issuer in the EUTL is actually 244 bytes long.
validFrom uint(11) A unix timestamp
validTo uint(11) A unix timestamp
serialNumber varchar(42) Hexadecimal string
subjectKeyIdentifier varchar(64) Index Hexadecimal string
certificate varchar(6000) The PEM encoded certificate (Largest certificate in the EUTL is e.g. 4381 bytes).
origin varchar(10) An unique identification of the origin.

We use SQLite for testing purpose. You can find the script that creates the table here and fills it with certificates of the EUTL.

Usage

Just create an instance of the PdoCollection class and pass it to e.g. the trusted certificates' collection:

$path = 'sqlite:path/to/db.sqlite';
$dbh  = new PDO($path);
$collection = new PdoCollection($dbh, '<VERSION-IDENTIFIER>');

$collector = new ValidationRelatedInfo\Collector();
$collector->getTrustedCertificates()->add($collection);
// ...

Please note that this class is only an example implementation and we build it in the setasign\SetaPDF2\Demos\Signer\X509\Collection namespace to show that it is only a demonstration. You should create your own implementation in your own namespace.

How to run the examples

For demonstration purpose we added demos, which rely on an SQLite database. You have to execute the script /examples/create-tbl.php to create the SQLite database in the /assets folder and import all certificates of the EUTL and AATL into it. The script will also write a timestamp into the file /assets/version.data which is later used by all examples as its trust list version identification.

Then you can simply execute any other script in the /examples folder.

What's the syntax of subject and issuer?

As such collection instances are mostly used internally by the SetaPDF-Signer component, the subject and issuer strings are internally generated by the DistinguishedName::getAsString() method based on an underlying ASN.1 structure.

This method makes use of a static DistinguishedName::$separator property, which is used to separate the individual parts of the name. This static property has to be kept in sync with how the data were stored in the database.

setasign/setapdf-signer-x509-pdo-collection 适用场景与选型建议

setasign/setapdf-signer-x509-pdo-collection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 setasign/setapdf-signer-x509-pdo-collection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 setasign/setapdf-signer-x509-pdo-collection 我们能提供哪些服务?
定制开发 / 二次开发

基于 setasign/setapdf-signer-x509-pdo-collection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-27