Új hozzászólás Aktív témák
-
peterszky
őstag
Lenne egy OpenSSL kérdésem:
$ openssl cms -verify -in signed_file -inform DER -CAfile key.pem > plain_file
Verification successfulEzt próbálom a C-s library segítségével egy programba átültetni, de nem igazán sikerült eddig megoldást találnom. A parancssori jól működik.
Az alap példából indultam ki, unable to get local issuer certificate hibával jön vissza.
/* Simple S/MIME verification example */
#include <openssl/pem.h>
#include <openssl/cms.h>
#include <openssl/err.h>
int main(int argc, char **argv)
{
BIO *in = NULL, *out = NULL, *tbio = NULL, *cont = NULL;
X509_STORE *st = NULL;
X509 *cacert = NULL;
CMS_ContentInfo *cms = NULL;
int ret = 1;
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
/* Set up trusted CA certificate store */
st = X509_STORE_new();
/* Read in CA certificate */
tbio = BIO_new_file(argv[1], "r");
if (!tbio)
goto err;
cacert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
if (!cacert)
goto err;
if (!X509_STORE_add_cert(st, cacert))
goto err;
/* Open message being verified */
in = BIO_new_file(argv[2], "r");
if (!in)
goto err;
/* parse message */
//cms = SMIME_read_CMS(in, &cont);
cms = d2i_CMS_bio(in, NULL);
if (!cms)
goto err;
/* File to output verified content to */
out = BIO_new_file(argv[3], "w");
if (!out)
goto err;
if (!CMS_verify(cms, NULL, st, cont, out, 0))
{
fprintf(stderr, "Verification Failure\n");
goto err;
}
fprintf(stderr, "Verification Successful\n");
ret = 0;
err:
if (ret)
{
fprintf(stderr, "Error Verifying Data\n");
ERR_print_errors_fp(stderr);
}
if (cms)
CMS_ContentInfo_free(cms);
if (cacert)
X509_free(cacert);
if (in)
BIO_free(in);
if (out)
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret;
}
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- AMD vs. INTEL vs. NVIDIA
- Samsung Galaxy Watch (Tizen és Wear OS) ingyenes számlapok, kupon kódok
- Netfone
- Nintendo Switch 2
- Sorozatok
- TCL LCD és LED TV-k
- Épített vízhűtés (nem kompakt) topic
- Spórolós topik
- Felhő alapú adattárolás (Dropbox, stb.)
- MWC 2026: Könnyen megmarkoltuk a Lenovo Legion Tab ötödik generációját
- További aktív témák...
- SZUPER Akcióban Új Bontatlan Dyson V15 Origin 3 év gyártói garanciával Azonnal Átvehető
- Makulátlan Dell14",core i5,8-32GB DDR4,MAGYAR Vil.bill,256-512GB SSD,jó akku,W11
- Újszerű ÉRINTŐS Dell,14"FullHd IPS,8.gen core i5(8x3,6Ghz)8-32GB/256-512GB,MAGYAR Vil.bill
- Megkímélt ÉRINTŐS Dell,14"FullHd IPS,core i5,8-32GB DDR4,MAGYAR Vil.bill,256-512GB SSD,jó akku,W11
- BESZÁMÍTÁS! Intel Core i9 11900KF 8 mag 16 szál processzor garanciával hibátlan működéssel
- Apple iPhone 16 Pro 128GB, Kártyafüggetlen, 1 Év Garanciával
- Samsung Galaxy S26 Ultra - Black - 512GB - BONTATLAN - 3 Év Jótállás
- iPhone 13 mini 128GB 100%(1év Garancia) - AKCIÓ
- BESZÁMÍTÁS! Asus EX-B365M i5 9600K 16GB DDR4 500GB SSD RX 5500 XT 8GB Zalman T3 Plus 600W
- HIBÁTLAN iPhone 13 Pro 256GB Sierra Blue-1 ÉV GARANCIA - Kártyafüggetlen, MS4662, 90% AKKSI
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
