小编XFa*_*tor的帖子

使用OpenSSL解密p7m格式的s / mime消息

我正在尝试使用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 …

openssl objective-c pkcs#7

1
推荐指数
1
解决办法
2847
查看次数

标签 统计

objective-c ×1

openssl ×1

pkcs#7 ×1