dbp/hcert-php

This package is abandoned and no longer maintained. No replacement package was suggested.

Making reading and verifying EU DCC in PHP easier

v0.3.0 2021-10-05 08:46 UTC

This package is auto-updated.

Last update: 2023-04-13 13:25:57 UTC


README

WARNING: This project is not ready for production (can't handle all signature types, missing signature verification for the trust data, and more) and is no longer actively supported. It was an experiment to see if verification of HCERTs was feasible with a PHP based web application but was abandoned half way through in favor of a client side Javascript based solution for non-technical reasons. If you are still interested in improving/completing this library please open an issue.

GitLab Repository | Packagist

Decode and verify the payload of an EU Digital Covid Certificate in PHP.

Installation

composer require dbp/hcert-php

Usage

use Dbp\Hcert\Hcert;
use Dbp\Hcert\TrustList;

TrustList::$trustListAnchor = '-----BEGIN CERTIFICATE-----
MIIBJTC...';
Hcert::$trustList = new TrustList();

$payload = 'HC1:NCFOXN%TS3D...';
try {
    $hcert = Hcert::fromQrcodePayload($payload, true);
    var_dump([
        $hcert->firstName(),
        $hcert->lastName(),
        $hcert->dayOfBirth(),
    ]);
} catch (Exception $e) {
    echo $e->getMessage() . PHP_EOL;
}

Use a local cached trust list:

use Dbp\Hcert\TrustList;

TrustList::$trustListAnchor = '-----BEGIN CERTIFICATE-----
MIIBJTC...';
$pathToTrustList = '.../trust-list.bin';

Hcert::$trustList = new TrustList($pathToTrustList);