PHP code example of ez-php / webauthn-metadata

1. Go to this page and download the library: Download ez-php/webauthn-metadata 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/ */

    

ez-php / webauthn-metadata example snippets


use EzPhp\WebauthnMetadata\{Aaguid, AttestationTrustVerifier, CurlBlobFetcher, FileBlobCache, MdsClient, MetadataBlobVerifier};

// The FIDO MDS root certificate (PEM) is supplied by you — it is never bundled.
$verifier = new MetadataBlobVerifier(file_get_contents('/etc/app/fido-mds-root.pem'));

$client = new MdsClient(new CurlBlobFetcher(), new FileBlobCache('/var/cache/app/mds.jwt'), $verifier);

$trust = new AttestationTrustVerifier($client);

// aaguid: raw 16 bytes from authenticatorData; x5c: attStmt['x5c'] (DER strings, leaf first)
$decision = $trust->verify(Aaguid::fromBinary($aaguidBytes), $x5c);

if (!$decision->trusted) {
    // $decision->reason explains why; $decision->entry is the matched MDS entry, if any
}
bash
composer