PHP code example of iberfacil / eidas-cert-auth

1. Go to this page and download the library: Download iberfacil/eidas-cert-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iberfacil / eidas-cert-auth example snippets


use Iberfacil\EidasCertAuth\Options;
use Iberfacil\EidasCertAuth\Transport\CurlTransport;
use Iberfacil\EidasCertAuth\Trust\{TrustListImporter, TrustStore, XmlSignatureVerifier};

$options = new Options(region: 'ES', countries: ['ES', 'PT']);
$store = new TrustStore('/path/to/private-data/trust', $options->minimumRetentionPercent);
$importer = new TrustListImporter(new CurlTransport(), new XmlSignatureVerifier(), $store, $options);
$preview = $importer->importLotl(dryRun: true);

use Iberfacil\EidasCertAuth\Cache\InMemoryRevocationCache;
use Iberfacil\EidasCertAuth\Certificate\{CertificateParser, CertificateValidator, RevocationChecker};

$validator = new CertificateValidator(
    new CertificateParser(), $store,
    new RevocationChecker(new CurlTransport(allowHttp: true), new InMemoryRevocationCache()),
    $options,
);
$resultado = $validator->validate($pemDeVariableServidor);
if (! $resultado->valid) {
    // Use $resultado->reason; no registre el PEM ni la identidad por defecto.
}

'profiles' => [
    'default' => [
        'countries' => ['ES'], 'qualified_     'soft_fail_revocation' => false,
    ],
    'login' => [
        'countries' => ['ES'], 'qualified_     'soft_fail_revocation' => false,
    ],
    'signature' => [
        'countries' => ['ES'], 'qualified_false,
        'soft_fail_revocation' => false,
    ],
],

// Ruta Laravel con el alias eidas.cert registrado por el proveedor:
Route::post('/firmar', $handler)->middleware('eidas.cert:signature');

// Núcleo sin Laravel o fachada Laravel:
$resultado = $validator->validate($pemDeVariableServidor, profile: 'signature');
nginx
ssl_verify_client optional_no_ca;
ssl_client_certificate /path/to/private-data/trust/bundle.pem;

location /certificate-login {
    s php_backend;
}
bash
php artisan eidas:trust-list:update --dry-run
php artisan eidas:trust-list:update
php artisan eidas:doctor