objective c - Decrypting s/mime messages in p7m format with OpenSSL -


i'm trying decrypt p7m openssl cannot go through error in following part of code:

pkcs7 *p7 = null;  in = bio_new_file(convertedresourcepath, "r");      if (in) {         nslog(@"opening p7m file");     }     else         nslog(@"cannot found p7m file");      out = bio_new_file(converteddecrfilepath, "w");      if (out) {         nslog(@"file decription has been created");     }     else         nslog(@"failed create decription file");       p7 = smime_read_pkcs7(in, null);  if (p7) {         nslog(@"start reading p7m file");      }     else {         nslog(@"cannot read p7m file");         err_print_errors_fp(stderr);     }   if (pkcs7_decrypt(p7, pkey, cert, out, 0)) {         nslog(@"file decrypted sucessfully!");     }     else         nslog(@"cannot decrypt file"); 

i got following in output:

opening p7m file 2013-07-22 12:45:22.951 smimeprototype[10827:c07] file decription has been created 2013-07-22 12:45:22.952 smimeprototype[10827:c07] cannot read p7m file 2900150892:error:0d0d40d1:asn1 encoding routines:smime_read_asn1:no content type:asn_mime.c:451: 2013-07-22 12:45:22.953 smimeprototype[10827:c07] cannot decrypt file

looking help, maybe p7 variable can initialized in other way?

i tried use

p7=d2i_pkcs7_bio(in,null); 

instead of

p7 = smime_read_pkcs7(in, null); 

and works great.

i hope someone.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -