PKCS12 file password verification error

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 can upload the file to p12, but could not verify the PKCS12 file. I get 0 as return from PKCS12_verify_mac .

Why does it return 0?

+1
source share
1 answer

Try using ERR_print_errors to find out the reason. 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); } 
+2
source

Source: https://habr.com/ru/post/1266561/


All Articles