Hello all,
I'm trying to run a loop to parse the same p12 multple times to take some
metrics. However, after the loop completes twice succesfully, PKCS12_parse
fails. Any suggestions as to why this is happening?
-Chris
while(count > 0){
/* Parse the PKCS #12 file with password */
ca = (STACK_OF(X509) *)NULL;
if (!PKCS12_parse(p12, "password", &pkey, &cert, &ca))
{
printf("Error parsing file\n");
return -3;
}
/* Find PKey */
if ( (EVP_PKEY *)NULL == pkey ){
//printf("No private key!\n");
}
else{
//printf("Private key found!\n");
}
/* Find Cert */
if ( (X509 *)NULL == cert ){
//printf("No X509!\n");
}
else{
//printf("X509 found!\n");
}
/* Find CA */
if ( (STACK_OF(X509) *)NULL == ca ){
//printf("No CA!\n");
}
else{
//printf("CA found!\n");
}
count--;
EVP_PKEY_free(pkey);
X509_free(cert);
sk_X509_pop_free(ca, X509_free);
}//end while