如何用PHP提取jarsigner创建的META-INF / CERT.RSA的内容?

时间:2014-12-04 18:58:52

标签: php apk pkcs#7 php-openssl

我特别想确定用于签署Android APK的密钥的到期日期。

该文件似乎是DER编码的PKCS#7,因为它显示了内容:

openssl pkcs7 -inform DER -in CERT.RSA -noout -print_certs -text

我尝试了一些方法:

/* try to open as pkcs#7.  prints FALSE. */

if( TRUE === openssl_pkcs7_verify ( 'CERT.RSA', 0 ) ) {
    echo "TRUE\n";
}
else {
    echo "FALSE\n";
}

/* try to open as an x509.  prints FALSE. */

$data = openssl_x509_parse(file_get_contents('CERT.RSA'));
if( $data === FALSE ) {
    echo "FALSE\n";
}

/*                                                                                                         
   un-DER with phpseclib                                                                                   

   prints a nestated data structure that clearly includes                                                  
   data from CERT.RDA, but unclear to me which value is                                                    
  the cert expiration date.                                                                               
*/

$ASN1 = new File_ASN1(file_get_contents('CERT.RSA'));
print_r( $ASN1->decodeBER(file_get_contents('CERT.RSA')) );`

可能只是从exec()或类似的东西调用openssl,但我宁愿拥有纯PHP解决方案。有人有一个吗?

0 个答案:

没有答案