Password verification of PKCS12 file failed

梦想的初衷 提交于 2019-12-08 07:29:13

问题


My code is:

   FILE * fp = fopen(inputdata, "r");
   PKCS12 * p12 = d2i_PKCS12_fp(fp, NULL);

    if (p12 == NULL)
    {
         NSLog(@"Error loading PKCS12 file to p12 \n"); 
    }
    if ((ret = PKCS12_verify_mac(p12,"tcs",3))){
        lblmsg.text = @"password validated"; 
        NSLog(@"Password validated %s",ppvc_pfxPassPhrase);
    }
    NSLog(@"ret value %d",ret);

I'm able to load the file to p12, but unable to verify the PKCS12 file. I'm getting 0 as the return from PKCS12_verify_mac.

Why is it returning 0?


回答1:


Try using ERR_print_errors to find out the cause. Example:

ret = PKCS12_verify_mac(p12, "tcs", 3);
if (ret == 0) {
    ERR_print_errors(stderr);
    // Abort?
} else {
    lblmsg.text = @"password validated"; 
    NSLog(@"Password validated %s",ppvc_pfxPassPhrase);
}


来源:https://stackoverflow.com/questions/8628576/password-verification-of-pkcs12-file-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!