Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ret check in pkcs12-example #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crypto/pkcs12/pkcs12-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ int main()
FILE *f;
int bytes, ret;

printf("extracting private key and certificate from PKCS12 (test-servercert.p12)\n");
printf("extracting private key and certificate from PKCS12"
" (test-servercert.p12)\n");

pkcs12 = wc_PKCS12_new();
if (pkcs12 == NULL) {
Expand All @@ -61,7 +62,8 @@ int main()

/* convert the DER file into an internal structure */
ret = wc_d2i_PKCS12(buffer, bytes, pkcs12);
printf("return value of d2i pkcs12 = %d %s\n", ret, (ret == 1)? "SUCCESS": "FAIL");
printf("return value of d2i pkcs12 = %d %s\n", ret,
(ret == 0) ? "SUCCESS": "FAIL");
if (ret != 0) {
printf("\t error converting pkcs12 to an internal structure\n");
wc_PKCS12_free(pkcs12);
Expand All @@ -71,7 +73,8 @@ int main()
/* parse the internal structure into its parts */
ret = wc_PKCS12_parse(pkcs12, "wolfSSL test", &keyDer, &keySz,
&certDer, &certSz, &list);
printf("return value of parsing pkcs12 = %d %s\n", ret, (ret == 1)? "SUCCESS": "FAIL");
printf("return value of parsing pkcs12 = %d %s\n", ret,
(ret == 0) ? "SUCCESS": "FAIL");
if (ret != 0 || keyDer == NULL || certDer == NULL) {
printf("\t error parsing pkcs12\n");
wc_PKCS12_free(pkcs12);
Expand Down