PHP code example of gaesi / cert

1. Go to this page and download the library: Download gaesi/cert 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/ */

    

gaesi / cert example snippets

` php
 use Gaesi\Cert\IcpBrasil\IcpBrasilCertificate;

 $icp = new IcpBrasilCertificate();
 $icp->parseSSL();

 echo $icp->cnpj;   // print the cnpj
 echo $icp->name;   // print the name of the CommonName
 echo $icp->oidExists('2.16.76.1.3.3'); // true

 
` php
 use Gaesi\Cert\IcpBrasil\IcpBrasilCertificate;

 $ca = new CALoader();
 $ca->addRepositoryPath('path/to/CAs/repository');
 
 $icp = new IcpBrasilCertificate();
 $icp->parseSSL();
 $icp->setChain($ca->getCAs());
 echo 'Valid? :'. ($icp->validateChain())? 'true' : 'false';
` php
 use Gaesi\Cert\IcpBrasil\IcpBrasilCertificate;


 $icp = new IcpBrasilCertificate();
 $icp->parseSSL();

 // Include the Intermediates Certs to the Chain
 $ca = new CALoader();
 $ca->addCerts( $intermediatesCert ); 
 
 $icp->setChain($ca->getCAs());
 echo 'Is IcpBrasil? :'. ($icp->validateICPBrasilChain())? 'true' : 'false';