CMS_add1_signer(cms, cert, key, NULL, CMS_REUSE_DIGEST ) returns NULL
Пытаюсь добавить подпись в уже сформированное signed data CMS, используя функцию OpenSSL
CMS_add1_signer()
Функция возвращает ноль. Что не так у меня? Прикрепляю код и данные cms, которые пытаюсь подписать.
inBio = BIO_new_file("cms_signed.pem", "r");
CHECK(" BIO_new_file", inBio != NULL, free_certCA);
cms = PEM_read_bio_CMS(inBio, NULL, NULL, NULL);
CHECK(" PEM_read_bio_CMS", cms != NULL, free_certCA);
key = getHardwareKeyPair();
CHECK(" get_key_pair", key != NULL, unregister_engine);
BIO_free_all(inBio);
inBio = BIO_new_file("certificate.cer", "r");
CHECK(" BIO_new_file", inBio != NULL, free_cms);
cert = PEM_read_bio_X509(inBio, NULL, NULL, NULL);
CHECK(" PEM_read_bio_X509", cert != NULL, free_in_bio);
CMS_SignerInfo* res = CMS_add1_signer(cms, cert, key, NULL, CMS_REUSE_DIGEST); //returns NULL
CMS:
-----BEGIN CMS-----
MIIEHAYJKoZIhvcNAQcCoIIEDTCCBAkCAQExDjAMBggqhQMHAQECAgUAMDIGCSqG
SIb3DQEHAaAlBCMxIDIgMyA0IDUgCk9ORSBUV08gVEhSRUUgRk9VUiBGSVZFCqCC
AmAwggJcMIIByKADAgECAgkAx8bflzOws5gwCgYIKoUDBwEBAwMwejEPMA0GA1UE
CAwGTW9zY293MQ8wDQYDVQQHDAZNb3Njb3cxFjAUBgNVBAoMDUFPIEFrdGl2LVNv
ZnQxEDAOBgNVBAsMB1J1dG9rZW4xLDAqBgNVBAMMI1J1dG9rZW4gVEVTVCBDQSAo
UCkgR09TVCBSIDIwMTItNTEyMB4XDTE5MTEwODA4MTMyM1oXDTIwMTEwODA4MTMy
M1owOjEUMBIGA1UEAwwLU3VwZXJLZXkyNTYxCzAJBgNVBAYTAlJVMRUwEwYDVQQI
DAzQnNC+0YHQutCy0LAwZjAfBggqhQMHAQEBATATBgcqhQMCAiMBBggqhQMHAQEC
AgNDAARALqfEeFXve4ovRzf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