herald-si / verificac19-sdk-php

PHP Digital Green Certificate SDK
Apache License 2.0
13 stars 6 forks source link

Unrecognized DCC certificate #31

Closed salalex closed 2 years ago

salalex commented 2 years ago

Hello, I think I found an issue in v1.0.8: the same valid EU DCC certificate which in v1.0.7 passes the verification, in v1.0.8 results in certificateStatus = NOT_EU_DCC.

Here is the test code:

#!/usr/bin/php
<?php
require __DIR__ . '/verificac19-sdk-php-1.0.8/vendor/autoload.php';
use Herald\GreenPass\Utils\CertificateValidator;
use Herald\GreenPass\Validation\Covid19\ValidationScanMode;

$gp_string = 'HC1:6BFOXN%TS3DHPVO13J /G-/2YRVA.Q/R8RNM2FC1J9M$DI9CAH9*$UZJ1*MIN9HNO4*J8OX4W$C2VL*LA/CJ/IE%TE6UG+ZEAT1HQ13W1:O1YUI%F1PN1/T1%%HRP5 R14SI.J9DYHZRO5$0ORN./G0OP748$NI4L6E QSO1VP8.P5*.RCU3S-J9+J**J ZPW:POYJ3+P8$RV-H%%H$%HTU1RR3BY5ZIEQKERQ8IY1I$HH%U8 9PS5OH6RWPOP6OH6MN96VHDV22JA.IEGW2TK2TH9YJA-LH/CJTK96L6SR9MU93FGRRJ/9TL4T1C9 UPMA9W1FOEEMK9YL0TNP8EFLEBQ-7BMOS0I6%5R6W9NTZ891-ST*QGTA4W7.Y7G+SB.V Q5 M9DQEEH0%YBOUQ05H4:R.AQBOH5THKMIS1R5N7LHHZ*1:MF9MAAE3/5O2:3$LLHPBCMLIBPXDT%LIZ53LYU+ARVRPZPI:J6S SPHDD%57HDMWF-VU3PGAOE/IHV4F';

// set scan mode to 3G (BASE)
$scanMode = ValidationScanMode::CLASSIC_DGP;
$gp_reader = new CertificateValidator($gp_string, $scanMode);
$gp_info = $gp_reader->getCertificateSimple();

echo($gp_info->certificateStatus.PHP_EOL);

I'm using PHP v7.4.26:

PHP 7.4.26 (cli) (built: Nov 16 2021 15:31:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies
DevPGS commented 2 years ago

Hi @salalex, I tested the HC1: the string and the library correctly return "VALID". Maybe you are missing some php modules required by COSE-lib. To verify the signature, the lib "Requires the GMP or bcmath extension.". If you use a php image from docker, those modules are not installed by default. You can use this command in DockerFile to install bcmath: RUN docker-php-ext-install bcmath

salalex commented 2 years ago

You are right, the php-bcmath extension was not installed on my system. I installed it and now it works. Thank you!