나는 비슷한 문제가있었습니다. PKCS # 7 서명에서 signingTime 특성을 추출해야했습니다. 인터넷에서 궁극적 인 해결책을 찾지 못했지만 여러 곳에서 부품과 부품을 집어 들고이를 해결할 수있었습니다. 어쩌면 더 좋고/더 좋고/더 안전한 방법이있을 수 있습니다. 처음에는이 방법을 사용했지만 효과가있는 것 같습니다.
함수에서 나는 const void * p_pkcs7Sig를 가리키는 버퍼에서 PKCS # 7 서명의 p_pkcs7SigSize 바이트를가집니다. 나는 서명하는 시간이있어. 오류 처리를 제거했습니다. 자세한 내용은이 코드를 사용하지 마십시오!
BIO *v_in = NULL;
PKCS7 *v_p7 = NULL;
STACK_OF(PKCS7_SIGNER_INFO) *v_signerInfos = NULL;
PKCS7_SIGNER_INFO *v_signerInfo = NULL;
ASN1_TYPE *v_asn1SigningTime = NULL;
/* make BIO for input buffer */
v_in = BIO_new_mem_buf((void*)(uintptr_t) p_pkcs7Sig, p_pkcs7SigSize);
/* make a PKCS7 object of it */
v_p7 = d2i_PKCS7_bio(v_in, NULL);
/* get all signer infos */
v_signerInfos = PKCS7_get_signer_info(v_p7);
/* if you need all signer infos then loop through all,
* count you get by k_PKCS7_SIGNER_INFO_num(v_signerInfos)
*/
/* get the first signer info */
v_signerInfo = sk_PKCS7_SIGNER_INFO_value(v_signerInfos,0);
/* get signing time */
v_asn1SigningTime = PKCS7_get_signed_attribute(v_signerInfo, NID_pkcs9_signingTime);
/* You should got a v_asn1SigningTime->type == V_ASN1_UTCTIME,
* if yes then the actual value is in the string buffer at
* v_asn1SigningTime->value.utctime->data
*/
if (v_in)
{
BIO_free_all(v_in);
v_in = NULL;
}
감사합니다. – openssid
Fudaraku, PKCS7 서명 코드 이미지에서 서명 된 콘텐츠를 가져올 수 있습니까? – openssid
안녕하세요. 답변을 얻었습니다. 지원해 주셔서 감사합니다. "aaa = PKCS7_verify (p7, certs, NULL, in, NULL, PKCS7_NOVERIFY);" 확인을 위해 일합니다. 서명 된 컨텐츠를 복사하는 경우 "aaa = PKCS7_verify (p7, certs, NULL, in, out, PKCS7_NOVERIFY);" 공장. char * p; long lSize; lSize = BIO_get_mem_data (출력, &p); p 포함 된 내용이 포함되어 있습니다. 감사합니다. – openssid