定制 setasign/trust-list-fetcher 二次开发

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

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

setasign/trust-list-fetcher

Composer 安装命令:

composer require setasign/trust-list-fetcher

包简介

A PHP package that allows you to download or extract all certificates from trust lists such as the EUTL or AATL.

README 文档

README

A PHP package licensed under the MIT that allows you to download or extract all certificates from trust lists such as the EUTL, Swiss Trust List (same format as the EUTL) or AATL.

Installation

You can install the package with Composer:

composer require setasign/trust-list-fetcher

The package uses classes of the SetaPDF-Signer component. A valid license and the correct composer repository has to be setup in your composer.json, too.

The root namespace for all classes is setasign/TrustListFetcher.

HTTP requests

All internal HTTP requests are done by a Client instance of Guzzle which is expected as an argument for the respective trust list class.

$client = new GuzzleHttp\Client([
    'verify' => __DIR__ . '/../assets/cacert-2026-04-16+interm-for-IE.pem'
]);

Certificates from the EUTL

The EtsiTL class allows you to download all certificates from the EUTL or trust lists from countries or international organizations adopted the same format (defined in ETSI TS 119 612).

Based on the Official Journal of the European Union (OJEU) on 14 April 2026 the class starts to load the "List Of Trust Lists" (LOTL) from https://ec.europa.eu/tools/lotl/eu-lotl.xml and recursively accesses the individual trust lists by the member states.

During this process the integrity and trust of the individual trust list signing certificates are verified. The process has to start with a collection of trusted certificates extracted from the mentioned OJEU which are stored in the file LOTL-signing-certificates-2026-04-15.pem.

//...
use setasign\SetaPDF2\Signer\PemHelper;
use setasign\SetaPDF2\Signer\X509\Collection;
//...

$trustedCerts = new Collection();
$trustedCerts->add(
    PemHelper::extractFromFile(__DIR__ . '/../assets/LOTL-signing-certificates-2026-04-15.pem')
);

Then you can simply initiate an instance:

//...
use setasign\TrustListFetcher\EtsiTL;
//...

$eutlFetcher = new EtsiTL($client, $trustedCerts, 'https://ec.europa.eu/tools/lotl/eu-lotl.xml');

The real process starts by calling the fetch() method, which accepts two callbacks: $certificateFound which is executed if a certificate is found and $certificateError which is executed if a certificate cannot be interpreted by the Certificate instance:

//...
use setasign\SetaPDF2\Signer\X509\Certificate;
//...

$eutlFetcher->fetch(
    function (Certificate $certificate) {
        // a certificate was successfully extract
    },
    function (\InvalidArgumentException $e, string $certificate) {
        // the resolved certificate could not be converted to a Certificate instance 
    }
);

If it is not possible to process all trust lists, the method will throw an Exception and the resolved certificates should be seen as incomplete.

NOTE: The whole process can take several seconds or minutes depending on the response times of the individual trust list endpoints.

Error Handling and Logging

Only if the fetch() call is executed without any thrown exception, the process can be seen as complete.

To understand what's happening in the whole process the Eutl instance allows you access to a default Logger instance by its getLogger() method.

You can enable direct output of the logger instance this way:

$eutlFetcher->getLogger()->setDirectOutput(true);

All logs will be echoed out directly.

If you only want to access the log in case of an exception, just access it in a catch-block:

try {
    $eutlFetcher->fetch(
        function (Certificate $certificate) {
            // ...
        },
        function (\InvalidArgumentException $e, string $certificate) {
            // ... 
        }
    );
   
    // commit all resolved certificates
    
} catch (\Throwable $e) {
    // revert or simply not process all resolved certificates
    
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
    foreach ($eutlFetcher->getLogger()->getLogs() as $logEntry) {
        echo \str_repeat(' ', $log->getDepth() * 4) . $log->getMessage() . PHP_EOL;
    }
}

Certificates from the AATL

The Aatl class allows you to download all certificates from the AATL.

The integrity and timestamp signature of the PDF envelope are validated by a root certificate for Adobe (Adobe Root CA G2.cer) and DigiCert (DigiCert Trusted Root G4.cer). For this we need a trusted certificate collection:

//...
use setasign\SetaPDF2\Signer\X509\Collection;
//...

$trustedCerts = new Collection();
$trustedCerts->addFromFile(__DIR__ . '/../assets/Adobe Root CA G2.cer');
$trustedCerts->addFromFile(__DIR__ . '/../assets/DigiCert Trusted Root G4.cer');

Then you can simply initiate an instance:

//...
use setasign\TrustListFetcher\Aatl;
//...

$aatlFetcher = new Aatl($client, $trustedCerts);

...and call the fetch() method to get all certificates from the AATL:

//...
use setasign\SetaPDF2\Signer\X509\Certificate;
//...

$aatlFetcher->fetch(
    function (Certificate $certificate) {
        // a certificate was successfully extract
    },
    function (\InvalidArgumentException $e, string $certificate) {
        // the resolved certificate could not be converted to a Certificate instance 
    }
);

Error Handling and Logging

Only if the fetch() call is executed without any thrown exception, the process can be seen as complete.

As the Eutl instance, the Aatl instance also allows you to access a logger instance by its getLogger() method.

You can enable direct output of the logger instance this way:

$aatlFetcher->getLogger()->setDirectOutput(true);

All logs will be echoed out directly.

If you only want to access the log in case of an exception, just access it in a catch-block:

try {
    $aatlFetcher->fetch(
        function (Certificate $certificate) {
            // ...
        },
        function (\InvalidArgumentException $e, string $certificate) {
            // ... 
        }
    );
   
    // commit all resolved certificates
    
} catch (\Throwable $e) {
    // revert or simply not process all resolved certificates
    
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
    foreach ($eutlFetcher->getLogger()->getLogs() as $logEntry) {
        echo \str_repeat(' ', $log->getDepth() * 4) . $log->getMessage() . PHP_EOL;
    }
}

setasign/trust-list-fetcher 适用场景与选型建议

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

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

围绕 setasign/trust-list-fetcher 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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