我特别想确定用于签署 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 解决方案。有人有吗?