我正在尝试使用 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:error:0D0D40D1 :asn1 编码例程:SMIME_read_ASN1:no content type:asn_mime.c:451: 2013-07-22 12:45:22.953 smimePrototype[10827:c07] 无法解密文件
寻求您的帮助,也许 p7 变量可以用其他方式初始化?