PHP How to parse pkcs7 signature blob?

守給你的承諾、 提交于 2019-11-30 20:39:49
kba

Unfortunatelly, I believe there is not simple solution. If you want to parse PKCS#7 DER encoded signature in PHP, you need some ASN.1 parser. OpenSSL functions in PHP are not capable to do it.

Do any PHP libraries exist for parsing ASN.1 or generating PHP code based on it?

Try to decode your DER data with some of referenced parsers. If any parser will work, you should be able to see and extract required information. As first step, you can try online parser from phpseclib project.

http://phpseclib.sourceforge.net/x509/asn1parse.php

What about this solution :)

<?php
    $result = shell_exec('openssl pkcs7 -inform DER -in signature.pkcs7 -print_certs -text');
    var_dump ($result);
    // you can use preg_match() if you want to parse something specific 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!