970_90

Tuesday, 2 October 2012

openssl_pkcs12_read

bool openssl_pkcs12_read ( string $pkcs12 , array &$certs , string $pass )
Parse a PKCS#12 Certificate Store into an array
openssl_pkcs12_read() parses the PKCS#12 certificate store supplied by pkcs12 into a array named certs.

$p12cert = array();
$file = '/home/mmacia/mycert.p12';
$fd = fopen($file, 'r');
$p12buf = fread($fd, filesize($file));
fclose($fd);
if ( openssl_pkcs12_read($p12buf, $p12cert, 'passphrase') ) 
{
    echo 'Works!';
    print_r($p12cert);
}
else
{  
    echo 'Fail';
}

No comments:

Post a Comment