如何提取由PHP创建的META-INF/CERT.RSA文件的内容?

如何提取由PHP创建的META-INF/CERT.RSA文件的内容?,php,apk,pkcs#7,php-openssl,Php,Apk,Pkcs#7,Php Openssl,我特别想确定用于签署Android APK的密钥的过期日期 该文件似乎是DER编码的PKCS7,这显示了以下内容: 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

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

该文件似乎是DER编码的PKCS7,这显示了以下内容:

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解决方案。有人有吗?

请显示您尝试过的代码。通常使用phpseclib时,您会在decodeBER之后调用$ASN1->asn1map$decodedBER、$map或类似的东西,但我不知道有任何pkcs7的映射可以与phpseclib一起使用,因此如果您想使用该路径,您必须创建自己的映射。