Extraer informacion de certificados del SAT

<?php function getCertificateData($fileContent) { $decodesContent = base64_encode($fileContent); $pieces = str_split($decodesContent, 64); array_unshift($pieces, '-----BEGIN CERTIFICATE-----'); array_push($pieces, '-----END CERTIFICATE-----'); $parse = openssl_x509_parse(implode("\r\n", $pieces)); if ($parse) { $companyData = [ 'razon_social' => $parse['subject']['name'], 'rfc' => trim(explode('/', $parse['subject']['x500UniqueIdentifier'])[0]), 'no_certificado' => gmp_export(gmp_init($parse['serialNumber'])), ]; return $companyData; } return false; } $cerFileContent = file_get_document('SAT.cer'); $cerData = getCertificateData($cerFileContent);
Este snippet extrae la informacion del certificado proporcionado por el SAT (Servicio de Administración Tributaria, de México). Util para sellar CFDIs.
Si te es de utilidad, agradecería tu donativo: https://goo.gl/yweH3o

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.