Giter VIP home page Giter VIP logo

verificac19-sdk-php's People

Contributors

darpins avatar devpgs avatar fpizzo20 avatar francesco-pizzo-i40awms avatar gmm9200 avatar herald-si avatar st4nny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

verificac19-sdk-php's Issues

revoked ucvi list too long

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

Errore validazione tipologia WORK

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

Errore Validazione Green Pass con issuer:"Department of Health Ireland"

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?

Validazione delle Certificazioni verdi Covid-19 errata rispetto a quanto implementati dal Ministero della Salute all’interno dell’applicazione governativa VerificaC19

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;
    }

Debug mode

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)

'Invalid signature length.' exception

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.

Nuova modalità di ingresso IT

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à:

  • aggiunte nuove impostazioni per la durata della vaccinazione completa per utenti di età inferiore ai 18 anni: 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 anni
  • aggiunta nel regolamento entry italy factory per applicare verifica con nuove impostazioni
  • aggiunta funzione per controllare l'età della persona per verificare se l'età è inferiore a 18

Commit di riferimento qui

Certificates scheduled refresh

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?

modalità di scansione WORK, è funzionante?

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?

Unrecognized DCC certificate

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 l'apposito header User-agent nelle richieste verso le API

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

'HC1: ' prefix missing

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.

Spomky-Labs/cbor-php version

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?

PARTIALLY_VALID conversion

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)

Errore loop infinito

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

update Verificac19.db

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

helper function to return decoded certificate

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.

Nuovo force update dei certificati sul backend

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

Errore Validazione Green Pass

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

compatibilità con php 7.3

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.