Skip to content

A PHP library to read and validate EU Digital COVID Certificates

License

Notifications You must be signed in to change notification settings

stw-on/covpasscheck-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CovPassCheck PHP

A PHP library to read and validate EU Digital COVID Certificates.

Install

composer require stwon/covpasscheck-php

Usage

Currently, the library only ships with a file based trust store. You need to download and store valid certificates manually or implement your own custom TrustStore class. The FileTrustStore reads JSON files matching the schema described here. Note that you MUST NOT include the signature part (i.e. first line) of DSC TrustList Update API responses.

$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

See LICENSE.md.

About

A PHP library to read and validate EU Digital COVID Certificates

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages