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.
}
// 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');