bio = BIO_new(BIO_s_mem());
if (!bio)
+ {
+ free(filename);
+ free(fullpath);
+ fclose (fp);
return -1;
+ }
status = i2d_PKCS12_bio(bio, context->pkcs12);
length = 2048;
x509_str = (BYTE*) malloc(length);
+ if (!x509_str)
+ {
+ free(filename);
+ free(fullpath);
+ fclose (fp);
+ return -1;
+ }
+
status = BIO_read(bio, x509_str, length);
if (status < 0)
+ {
+ free(x509_str);
+ free(filename);
+ free(fullpath);
+ fclose (fp);
return -1;
+ }
offset += status;
}
if (status < 0)
+ {
+ free(x509_str);
+ free(filename);
+ free(fullpath);
+ fclose (fp);
return -1;
-
+ }
length = offset;
fwrite((void*) x509_str, length, 1, fp);