Hi Steve, First thanks for the quick response.
Well, this function is mine, it's not the problem. you can see the function below : int POLICY_add_attrib(PKCS7_SIGNER_INFO *si, POLICYINFO *pInfo) { ASN1_STRING *seq; unsigned char *p, *pp ; int len; len = i2d_POLICYINFO(pInfo, NULL); pp = (unsigned char *) OPENSSL_malloc(len); p = pp; i2d_POLICYINFO(pInfo, &p); seq = ASN1_STRING_new(); ASN1_STRING_set (seq, pp, len); OPENSSL_free(pp); int nidPolicy = OBJ_create("1.2.840.113549.1.9.16.2.15", "id_aa_ets_sigPolicyId", "id_aa_ets_sigPolicyId"); return PKCS7_add_signed_attribute(si, nidPolicy, V_ASN1_SEQUENCE, seq); } The problem is when I pass to this function an POLICYINFO object with an POLICYQUALINFO that has an pqualid value other than "NID_id_qt_cps". If I don't use : pQInfo->pqualid = OBJ_nid2obj(NID_id_qt_cps); And use : int NID_id_spq_ets_uri = OBJ_create("1.2.840.113549.1.9.16.5.1", "id_spq_ets_uri", "id_spq_ets_uri"); pQInfo->pqualid = OBJ_nid2obj(NID_id_spq_ets_uri); For example, or wherever other NID or created NID the code crashs on : len = i2d_POLICYINFO(pInfo, NULL); Understand? Thanks in advance. Rogério On Jan 23, 2014, at 20:27 , Dr. Stephen Henson <st...@openssl.org> wrote: > On Thu, Jan 23, 2014, Rogrio Saulo wrote: > >> Hi all, >> >> Sorry if it as a stupid question but... >> >> I'm trying to add an custom policy qualifier attribute with another NID >> different from NID_id_qt_cps to an PKCS7 envelope. >> >> If I use the NID_id_qt_cps all works fine, BUT if I change the NID to >> another created by OBJ_create the program crashes at thei2d_POLICYINFO >> function. >> >> I cannot use the POLICYQUALINFO object with another NID different from >> NID_id_qt_cps?? >> >> There is my working code : >> >> ASN1_OBJECT *polID; >> POLICYINFO *pInfo = POLICYINFO_new(); >> polID = OBJ_txt2obj("2.16.76.1.7.1.2.2.1", 0); >> pInfo->policyid = polID; >> POLICYQUALINFO *pQInfo; >> pQInfo = POLICYQUALINFO_new(); >> pInfo->qualifiers = sk_POLICYQUALINFO_new_null(); >> pQInfo = POLICYQUALINFO_new(); >> sk_POLICYQUALINFO_push(pInfo->qualifiers, pQInfo); >> pQInfo->pqualid = OBJ_nid2obj(NID_id_qt_cps); >> pQInfo->d.cpsuri = M_ASN1_IA5STRING_new(); >> char *urlPolitica = "http://politicas.icpbrasil.gov.br/PA_AD_RT_v2_1.der"; >> ASN1_STRING_set(pQInfo->d.cpsuri, urlPolitica, strlen(urlPolitica)); >> POLICY_add_attrib(si, pInfo); // WORKS FINE >> >> If I change the line : >> >> pQInfo->pqualid = OBJ_nid2obj(NID_id_qt_cps); >> >> With : >> >> int NID_id_spq_ets_uri = OBJ_create("1.2.840.113549.1.9.16.5.1", >> "id_spq_ets_uri", "id_spq_ets_uri"); >> pQInfo->pqualid = OBJ_nid2obj(NID_id_spq_ets_uri); >> >> The program crashes at function POLICY_add_attrib in THIS LINE : >> >> int len = i2d_POLICYINFO(pInfo, NULL); >> >> What I'm doing wrong??? >> > > There isn't an OpenSSL function call POLICY_add_attrib. > > Steve. > -- > Dr Stephen N. Henson. OpenSSL project core developer. > Commercial tech support now available see: http://www.openssl.org > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-users@openssl.org > Automated List Manager majord...@openssl.org