承接 andreygrin/xades-tools 相关项目开发

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

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

andreygrin/xades-tools

最新稳定版本:1.0.1

Composer 安装命令:

composer require andreygrin/xades-tools

包简介

Sign files, xml content and verify signatures using XAdES

README 文档

README

Updated version, includes IssuerSerial information with cert serial number and issuer details.

API:

Signing

use XadesTools\CertificateFactory;
use XadesTools\Signature;
$cert = CertificateFactory::string(
    $privateKeyContents, // .pem
    $certificateContents, // .crt
    $parivateKeyPassword // string
);

$this->signer = new Signature($cert);
$this->signer->signXml('xmlContent') // returns signature, you should add it to the xml file the way you need to have it there.

Verification, content extraction

use XadesTools\Verification;
$xades = new Verification();
$result = $xades->verifyFile($pathToXadesFile);
if ($result) {
    $content = $res->content; // binary content or plain text for xml files
    $signTime = $res->dateSigned; // DateTime object
    $signingSubject = $res->signingSubject; // array
} else {
    // Signature does not match signed content
}

COMMAND LINE USAGE:

Signing file

php bin/sign.php file cert pass [embed] [load-content]

Where:

  • file - path to file we want to sign. Signature will be created in the same folder, with .XAdES extension
  • cert - certificate in PKCS#12 format (.p12) - with private key
  • pass - password for p12 file
  • embed - if true, signature will embed given file
  • load-content - loads file content into variable and signs it as embedded object

Results in file.XAdES located in the same directory as given file

Verification

php src/verify.php file [verbose]

Where:

  • file is path to .XAdES file
  • verbose if true print additional info about sign time and
  • load-content - loads file content into variable and verifies it as embedded object (can not rely on files on disk)

Verifies content in given XAdES file, prints OK if everything passes, error message otherwise.

Extracting file from XAdES files

php src/extract.php file output

Where:

  • file is path to .XAdES file with embedded object
  • output path for output file

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-24