The feimx/csd_converter
package provide a simple way for create .pem files for your CSD's.
You can install the package via composer:
composer require feimx/csd_converter
Firt need create a new instance of CsdConverter
:
$converter = new FeiMx\Csd\CsdConverter();
echo $converter->serial_number();
Thats all, now you can access the cer info and save the news files to given path
echo $converter->serial_number;
echo $converter->tax_id;
echo $converter->valid_from; // instance of Carbon
echo $converter->valid_to; // instance of Carbon
echo $converter->getStatus();
valid_from
and valid_to
are instances of Carbon, so you can modify and format the dates:
echo $converter->valid_from->format('d/m/Y h:i a');
echo $converter->valid_to->format('d/m/Y h:i a');
getStatus()
returns a expired, valid or invalid status:
if($converter->getStatus() === CsdConverter::VALID){}
if($converter->getStatus() === CsdConverter::INVALID){}
if($converter->getStatus() === CsdConverter::EXPIRED){}
You can verify if the files are a valid CSD:
var_dump($converter->isValidCsd()); // true or false
Now you can save the created files to a given path and assigne a optional filename:
$path = __DIR__.'/temp/';
$filename = 'VALIDCSD';
$converter->save($path, $filename);
//this create 4 files:
//__DIR__.'/temp/VALIDCSD.cer'
//__DIR__.'/temp/VALIDCSD.cer.pem'
//__DIR__.'/temp/VALIDCSD.key'
//__DIR__.'/temp/VALIDCSD.key.pem'
And last, but not less important, you can encryp the converted key into des3:
$file = __DIR__.'/temp/VALIDCSD.key.pem';
$password = 'secret';
$converter->encryptKey($file, $password);
//__DIR__.'/temp/VALIDCSD.enc.key'
Note: This is very useful with third party provider such as Finkok for stamp the CFDI
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
FEI is a Digital Invoicing startup based in Yucatán, México. You'll find an overview of all our open source projects on our website.
Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
The MIT License (MIT). Please see License File for more information.