我试图用OpenSSL解密p7m,但我不能在代码的以下部分中解决错误:
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 for decription has been created");
}
else
NSLog(@"failed to 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");
我在输出中得到以下内容:
打开p7m文件2013-07-22 12:45:22.951 smimePrototype [10827:c07]文件已解密已创建2013-07-22 12:45:22.952 smimePrototype [10827:c07]无法读取p7m文件2900150892:错误: 0D0D40D1:asn1编码例程:SMIME_read_ASN1:无内容类型:asn_mime.c:451:2013-07-22 12:45:22.953 smimePrototype [10827:c07]无法解密文件
寻找你的帮助,也许p7变量可以用其他方式初始化?
1 回答
我试着用
代替
而且效果很好 .
我希望它会帮助某人 .