stwon / covpasscheck-php
1.5.3
2021-11-20 09:45 UTC
Requires
- php: >=8.0
- ext-openssl: *
- ext-zlib: *
- composer/semver: ^3.2
- mhauri/base45: ^0.1.1
- nesbot/carbon: ^2.54
- spomky-labs/cbor-php: dev-byte-string-encode-fix
- web-auth/cose-lib: ^3.3
README
这是一个PHP库,用于读取和验证欧盟数字COVID证书。
安装
composer require stwon/covpasscheck-php
使用
目前,该库仅包含基于文件的信任存储。您需要手动下载并存储有效的证书,或者实现自己的自定义 TrustStore
类。 FileTrustStore
读取与以下文档中描述的架构匹配的JSON文件。请注意,您绝对不应该包含DSC信任列表更新API响应的签名部分(即第一行)。
$trustStore = new FileTrustStore('./certs.json'); $check = new CovPassCheck($trustStore); try { // This is the scanned QR code content ↓ $certificate = $check->readCertificate('HC1:...'); $subject = $certificate->getSubject(); if ($certificate->isCovered(Target::COVID19, HealthCertificate::TYPE_VACCINATION | HealthCertificate::TYPE_RECOVERY)) { $this->line($subject->getFirstName() . ' does conform to 2G rules.'); } else { $this->line($subject->getFirstName() . ' does not conform to 2G rules.'); } } catch (InvalidSignatureException $exception) { // oh noo }
许可证
查看LICENSE.md。