php解析处理pfx\cer\pem证书

2015-7-9 / 0评 /

本文共计 1059 字,感谢您的耐心浏览与评论。

一.pfx格式证书处理
//获取证书详细信息
$pkcs12certdata = file_get_contents ( $cert_path );
openssl_pkcs12_read ( $pkcs12certdata, $certs, SDK_SIGN_CERT_PWD );
$x509data = $certs ['cert'];
openssl_x509_read ( $x509data );
//通过打印certdata可查看证书详细信息
$certdata = openssl_x509_parse ( $x509data );
$cert_id = $certdata ['serialNumber'];
2.签名
$pkcs12    = file_get_contents($pri_key_dir);
openssl_pkcs12_read($pkcs12, $certs, $sign_cert_pwd);
$sign_falg = openssl_sign($data, $signature, $certs['pkey'], OPENSSL_ALGO_SHA1);
二.cer格式证书处理
//获取证书序列号serialNumber
$x509data = file_get_contents($cert_path);
openssl_x509_read($x509data);
$certdata = openssl_x509_parse($x509data);
$cert_id  = $certdata ['serialNumber'];
2.验签
$pub_key = file_get_contents($pub_key_dir);
$result  = openssl_verify($data, $sign, $pub_key,OPENSSL_ALGO_SHA1);

声明:多春鱼吧|版权没有,违者不究|转发请注明出处

转载:转载请注明原文链接 - php解析处理pfx\cer\pem证书

0条回应:“php解析处理pfx\cer\pem证书”

发表评论