(PHP 7 >= 7.2.0, PHP 8)
openssl_pkcs7_read — 將 PKCS7 檔案匯出為 PEM 憑證陣列
資料
您想要解析的資料字串 (p7b 格式)。
certificates (憑證)
從 p7b 輸入資料中取得的 PEM 憑證陣列。
範例 #1 從 P7B 檔案取得 PEM 陣列
<?php
$file = 'certs.p7b';
$f = file_get_contents($file);
$p7 = array();
$r = openssl_pkcs7_read($f, $p7);
if ($r === false) {
printf("錯誤:%s 不是正確的 p7b 檔案".PHP_EOL, $file);
for($e = openssl_error_string(), $i = 0; $e; $e = openssl_error_string(), $i++)
printf("SSL l%d: %s".PHP_EOL, $i, $e);
exit(1);
}
print_r($p7);
?>