php - Read and parse .cer file -
php - Read and parse .cer file -
i have certificate (.cer) have read de basic info of certificate, expiration date.
i wrote code in php
class firmaelectronica { public function abrircertificado( $path ){ $cert_content = file_get_contents( $path ); $res = openssl_x509_read( $cert_content ); $data = openssl_x509_parse( $res ); var_dump( $data ); } } $firma = new firmaelectronica(); $firma->abrircertificado('gohl881206rga.cer');
but warning , empty array of data
php warning: openssl_x509_read(): supplied parameter cannot coerced x509 certificate!
if execute command certificate data
openssl x509 -in gohl881206rga.cer -noout -text -inform der
what right way certificate info php?
using phpseclib..
<?php include('file/x509.php'); $x509 = new file_x509(); $cert = $x509->loadx509('...'); echo $cert['tbscertificate']['validity']['notbefore'] . "\r\n"; echo $cert['tbscertificate']['validity']['notafter'];
if doesn't work can post actual cert you're trying info from?
php ssl
Comments
Post a Comment