PHP8 openssl_pkcs7_read

2024-03-12 12:01 更新

(PHP 7 >= 7.2.0, PHP 8)

openssl_pkcs7_read — 將 PKCS7 文件導(dǎo)出為 PEM 格式證書的數(shù)組

說明

openssl_pkcs7_read(string $data, array &$certificates): bool

本函數(shù)還未編寫文檔,僅有參數(shù)列表。

參數(shù) 

data

想要解析的字符串?dāng)?shù)據(jù)(p7b 格式)。

certificates

PEM 格式證書的數(shù)組,來源于輸入的 p7b 數(shù)據(jù)。

返回值 

成功時(shí)返回 true, 或者在失敗時(shí)返回 false。

示例 

示例 #1 根據(jù) P7B 文件獲取 PEM 數(shù)組

<?php

$file = 'certs.p7b';

$f = file_get_contents($file);
$p7 = array();
$r = openssl_pkcs7_read($f, $p7);

if ($r === false) {
    printf("ERROR: %s is not a proper p7b file".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);
?>

參見 

  • openssl_csr_sign() - 用另一個(gè)證書簽署 CSR(或者本身)并且生成一個(gè)證書


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)