herald-si / verificac19-sdk-php Goto Github PK
View Code? Open in Web Editor NEWPHP Digital Green Certificate SDK
License: Apache License 2.0
PHP Digital Green Certificate SDK
License: Apache License 2.0
Rimuovere e adeguarsi all'ultima versione del SDK ufficiale rimuovendo la modalità di ingresso IT. CHANGELOG
The current revocation list check is too slow and saturates the memory.
The verification logic must be changed without download the full list from database
Risultato verifica: [certificateStatus] => NOT_EU_DCC
per certificato valido.
Lo stesso certificato in debug mode viene validato correttamente.
Di seguito il debug della mia applicazione in debug_mode e in modalità standard acquisendo lo stesso certificato:
14:42:39 Herald\GreenPass\Model\CertificateSimple Object
(
[person] => Herald\GreenPass\Model\SimplePerson Object
(
[standardizedFamilyName] => DISABLE-DEBUG-MODE-IN-PRODUCTION
[familyName] => DISABLE-DEBUG-MODE-IN-PRODUCTION
[standardisedGivenName] => DISABLE-DEBUG-MODE-IN-PRODUCTION
[givenName] => DISABLE-DEBUG-MODE-IN-PRODUCTION
)
[dateOfBirth] => DateTimeImmutable Object
(
[date] => 1968-05-27 00:00:00.000000
[timezone_type] => 3
[timezone] => Europe/Berlin
)
[certificateStatus] => VALID
[timeStamp] => DateTimeImmutable Object
(
[date] => 2022-02-02 14:42:39.487618
[timezone_type] => 3
[timezone] => Europe/Berlin
)
)
14:42:39 DISABLE-DEBUG-MODE-IN-PRODUCTION DISABLE-DEBUG-MODE-IN-PRODUCTION - 1968-05-27
14:42:39 27/05/1968
14:42:39 VALIDO
14:42:39 IMPOSSIBILE ACCEDERE AL DB
14:42:58
14:42:58 Herald\GreenPass\Model\CertificateSimple Object
(
[person] =>
[dateOfBirth] =>
[certificateStatus] => NOT_EU_DCC
[timeStamp] => DateTimeImmutable Object
(
[date] => 2022-02-02 14:42:58.788733
[timezone_type] => 3
[timezone] => Europe/Berlin
)
)
14:42:58 -
14:42:58 //
14:42:58 NON VALIDO
Questa mattina, ho avuto un errore di validazione per due Green Pass irlandesi.
Sto utilizzando la versione 1.4.1.
L'errore è dovuto ad un non corretto riconoscimento nella lettura del CBOR dei campi doseGiven e totalDoses.
Nel CBOR in questione viene utilizzato il Major Type 7.
Qualcuno ha sperimentato una situazione simile?
Like #43 but with {delta: {deletions}}
La verifica della certificazione verde da guarigione non è uguale a quanto quanto implementati dal Ministero della Salute all’interno dell’applicazione governativa VerificaC19. Il test di un greenpass valido per la guarigione è considerato valido nell'app VerificaC19 e fallisce con SDK php.
Non c'è il caso CertificateStatus.PARTIALLY_VALID.
SDK Android C19
private fun checkRecoveryStatements(it: List<RecoveryModel>): CertificateStatus {
try {
val startDate: LocalDate =
LocalDate.parse(clearExtraTime(it.last().certificateValidFrom)).plusDays(
Integer.parseInt(getRecoveryCertStartDay())
.toLong()
)
val endDate: LocalDate =
LocalDate.parse(clearExtraTime(it.last().certificateValidUntil))
Log.d("dates", "start:$startDate end: $endDate")
return when {
startDate.isAfter(LocalDate.now()) -> CertificateStatus.NOT_VALID_YET
LocalDate.now()
.isAfter(
startDate.plusDays(
Integer.parseInt(getRecoveryCertEndDay())
.toLong()
)
) -> CertificateStatus.NOT_VALID
LocalDate.now()
.isAfter(endDate) -> CertificateStatus.PARTIALLY_VALID
else -> CertificateStatus.VALID
}
} catch (e: Exception) {
return CertificateStatus.NOT_VALID
}
}
SDK php
private static function verifyRecoveryStatement($cert, $validation_date)
{
$data_inizio_validita = $cert->validFrom;
$data_fine_validita = $cert->validUntil;
if ($validation_date < $data_inizio_validita) {
return ValidationStatus::NOT_VALID_YET;
}
if ($validation_date > $data_fine_validita) {
return ValidationStatus::EXPIRED;
}
return ValidationStatus::VALID;
}
The current ministero-salute specifications require the download to be performed only every 24 hours, it is not possible to force the update except for debugging purposes.
I will add another configuration to the file to set the debug mode to the greenpass validator. Also if debug mode is on, I will send chained errors to "NOT_EU_DCC" to allow for more efficient testing during development. Clearly in production it cannot be used.
I close this pull request and create a new branch with your code.
Originally posted by @herald-si in #58 (comment)
Examining some certificates with country code CH we found a signature 256 bytes long and consequently they fail the 64 length check in the function ECSignature :: toAsn1.
The behavior looks different in the SDK-Android.
Hi
Thanks for the SDK, I try to use your code to NZ verification, but i am getting "Not a valid certificate. Not a CoseSign1 type" error.
Details are below
https://nzcp.covid19.health.nz/#example-resolving-an-issuers-identifier-to-their-public-keys
I have decoded the string to hex, next step fails "Not a valid certificate. Not a CoseSign1 type"
What am I doing wrong?
Thanks
hello,
i test my recovery green pass with the scan mode booster(RSA or 3 doses) and the output is valid.
But the real output not is need test?
Implementare nuova modalità di ingresso IT con regole per ingresso a utenti di età inferiore ai 18 anni, nello specifico sono state sviluppate lato SDK Android le seguenti funzionalità:
vaccino_end_day_complete_under_18
per il numero di giorni da aggiungere e under_18_offset
per aggiungere eventualmente alcuni giorni in modo da consentire agli utenti di completare la vaccinazione pochi giorni dopo aver compiuto 18 anniCommit di riferimento qui
Buonasera,
si prega di procedere all'aggiornamento del core di questo SDK per allineamento a release DGC-SDK Android/Kotlin 1.1.11.
Rimozione delle modalità di verifica RSA (booster) e Rafforzata (2G)
Aggiornamento del flusso di validazione con solo i controlli previsti per la modalità di verifica Base (3G)
Maggiori dettagli: ministero-salute/it-dgc-documentation#29
Hi,
I was wondering if might be useful to refactor the certificates management in a separate class which might offer a method to download/refresh certificates "on demand". Currently, if certificates don't exist or are expired, you are downloading them of the first certificate validation attempt and usually, that request takes few seconds to complete.
A useful feature to be able to call a method every 24h to refresh the certificates automatically.
What do you think about?
Buonsera,
ho testato l'ultima rel (1.4.3) con le nuove modalità di scansione, con quella work ottengo su tutti quelli testati:
certificateStatus: NOT_EU_DCC
person e dateOfBirth NULL
è normale?
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
Inserire all'interno delle richieste verso le API l'apposito header User-Agent nella forma
User-Agent: <sdk>-<sdk-technology>/<sdk-version>
È possibile omettere -<sdk-technology>
se la tecnologia è già specificata nel nome (ad esempio verificac19-sdk-php).
Ad esempio nel caso verificac19-sdk
per Node.js lo User-Agent sarà
User-Agent: verificac19-sdk-node/0.9.3
When the qrcode lacks the initial part 'HC1:' the verification fails because it considers it mandatory. In the SDK-Android version the check is done only to eliminate the possible prefix, but it does not generate an exception.
Hi,
I saw you used a particular version of the library but seems like that it creates some issue with composer:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires herald-si/verificac19-sdk-php ^1.0.7 -> satisfiable by herald-si/verificac19-sdk-php[v1.0.7].
- herald-si/verificac19-sdk-php v1.0.7 requires spomky-labs/cbor-php dev-string-encode-fix -> found spomky-labs/cbor-php[v1.0.0, ..., v1.1.x-dev, v2.0.0, v2.0.1, v2.0.x-dev, v2.1.x-dev, v3.0.0, v3.0.x-dev] but it does not match the constraint.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Is there any particular reason why version 3.0 can't be used?
there was an issue with PARTIALLY_VALID and Recovery, the check with status triggered before the BOOSTER check.
Booster mode must return different PARTIALLY_VALID conversion based on Certificate Type:
BOOSTER + Vaccine + PARTIALLY_VALID -> [NOT_VALID] https://github.com/ministero-salute/it-dgc-documentation/blob/master/SCANMODE.md#flussi-vaccinazione
BOOSTER + Recovery + PARTIALLY_VALID -> [TEST_NEEDED] https://github.com/ministero-salute/it-dgc-documentation/blob/master/SCANMODE.md#flussi-guarigione
So, to make it easier to understand, i removed completely the PARTIALLY_VALID status (already deprecated). I close this PR and create a new one without that status.
Thank you @darpins
Originally posted by @DevPGS in #70 (comment)
Ciao a tutti,
se provo ad eseguire il seguente codice di esempio:
require __DIR__ . '/verificac19-sdk-php/vendor/autoload.php';
use Herald\GreenPass\Utils\CertificateValidator;
$gp_string = 'HC1:6B..MIASTRINGA';
$gp_reader = new CertificateValidator($gp_string);
$gp_info = $gp_reader->getCertificateSimple();
// Mostro la struttura dell'esito validazione
echo "<pre>" . print_r($gp_info, true) . "</pre>";
Ricevo il seguente errore:
Fatal error: Uncaught Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames in /var/www/html/testgp/verificac19-sdk-php/src/Utils/EndpointService.php on line 92
Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames in /var/www/html/testgp/verificac19-sdk-php/src/Utils/EndpointService.php on line 92
...dove sbaglio?
Grazie mille in anticipo
Ciao @herald-si ,
sto facendo gli sviluppi e osservavo la gestione delle revoche grazie al file Verificac19.db il quale si aggiorna con riferimento al file it-gov-dgc-drl-status.json.
Mi sono reso conto che se io non utilizzo l'applicazione e non aggiorno i 2 file per qualche giorno, questo mi aggiorna solo una versione successiva a quella presente nel file it-gov-dgc-drl-status.json.
Faccio un esempio:
contenuto del file it-gov-dgc-drl-status.json prima dell'update:
{chunk":1,"version":34,"validity":"VALID","info":null}
chiamate uri in fase dell'update
https://get.dgc.gov.it/v1/dgc/drl/check?version=34
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=1
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=2
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=3
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=4
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=5
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=6
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=7
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=8
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=9
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=10
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=11
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=12
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=13
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=14
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=15
https://get.dgc.gov.it/v1/dgc/drl?version=34&chunk=16
https://get.dgc.gov.it/v1/dgc/drl/check?version=37
contenuto del file it-gov-dgc-drl-status.json dopo l'update:
{"chunk":1,"version":37,"validity":"VALID","info":null}
Quindi sembra che il db non venga aggiornato con le versioni 35 e 36.
E' corretto così o un bug?
Grazie
Carlo Alberto
Hello.
Great library. I was thinking it would be possible to add an extra function returning the decoded qr code. Basically returning $cbor['data'][- 260][1] without wrapping into a GreenPass().
Thank you in advance,
M.
Buongiorno,
avvisiamo che dalla settimana prossima verrà effettuato un force update dei certificati sul backend di produzione (get.dgc) e di test (testaka4). Nel caso questo SDK fa uso di un check dei certificati, contattatemi nello Slack pubblico developersitalia.slack.com in modo che possa condividerveli, altrimenti chiudete pure questa issue.
Saluti,
AS
In vista dell'aggiornamento SDK apro qua una richiesta di cambiamento per il SDK in questione.
L'opzione è stata eliminata in quanto fino al 30 aprile è possibile per tutti, compresi gli over 50, accedere ai luoghi di lavoro con il green pass BASE, come previsto dal DECRETO-LEGGE 24 marzo 2022, n. 24.
Buongiorno,
vista l'ultima versione di verificaC19 volevo visionare il flusso documentale per il green pass esenzione.
Sul repository del ministero della salute(https://github.com/ministero-salute/it-dgc-documentation/blob/master/SCANMODE.md) non mi è sembrato di vederlo. C'è qualche altro riferimento documentale a riguardo?
Saluti
Carlo Alberto
Salve,
Praticamente sto provando ad utilizzare l'SDK per php, ma dopo la validazione ottengo sempre la stessa risposta. Ovvero:
object(Herald\GreenPass\Utils\CertificateValidator)[46]
private 'greenPassSimple' =>
object(Herald\GreenPass\Model\CertificateSimple)[50]
public 'person' => null
public 'dateOfBirth' => null
public 'certificateStatus' => string 'NOT_EU_DCC' (length=10)
public 'timeStamp' =>
object(DateTimeImmutable)[55]
public 'date' => string '2022-01-18 16:23:42.150655' (length=26)
public 'timezone_type' => int 3
public 'timezone' => string 'Asia/Kolkata' (length=12)
private 'scanMode' => string '3G'
Ovviamente il certificato validato con l'app VerificaC19 è valido
Buongiorno, da questa mattina non riesco più a scaricare i certificati, abilitando il debug, ricevo questo errore:
"No response was returned from website https://get.dgc.gov.it/v1/dgc/signercertificate/update"
Attendo cortese riscontro
Carissimi grazie per il vostro contributo.
Mi chiedevo, ci sono particolari librerie utilizzate nel progetto che necessitano di php 7.4
posto come requisito?
La vecchia versione, provata a far girare con qualche gp di test funzionava correttamente anche con php 7.3,
ora con quella attuale chiaramente non funziona poichè sono stati specificati dei tipi su alcune varibili.
Grazie
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.