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