我正在尝试使用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");
Run Code Online (Sandbox Code Playgroud)
我的输出如下:
正在创建用于解密的p7m文件2013-07-22 12:45:22.951 smimePrototype …