Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ AC_CHECK_LIB([wolfssl],[wolfCrypt_Init],,[AC_MSG_ERROR([libwolfssl is required a
AM_CFLAGS="$AM_CFLAGS -DHAVE_WOLFSSL_OPTIONS"

# check for some conditional functions
AC_CHECK_FUNC([wolfSSL_X509_CRL_print],
[],
[AM_CFLAGS="$AM_CFLAGS -DNO_WOLFSSL_CRL_PRINT"])
AC_CHECK_FUNC([wolfSSL_X509_REQ_print],
[],
[AM_CFLAGS="$AM_CFLAGS -DNO_WOLFSSL_REQ_PRINT"])
Expand Down
40 changes: 33 additions & 7 deletions src/sign-verify/clu_crl_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static const struct option crl_options[] = {
{"-inform", required_argument, 0, WOLFCLU_INFORM },
{"-outform", required_argument, 0, WOLFCLU_OUTFORM },
{"-CAfile", required_argument, 0, WOLFCLU_CAFILE },
{"-text", no_argument, 0, WOLFCLU_TEXT_OUT },
{"-noout", no_argument, 0, WOLFCLU_NOOUT },
{"-help", no_argument, 0, WOLFCLU_HELP },
{"-h", no_argument, 0, WOLFCLU_HELP },
Expand All @@ -51,7 +52,8 @@ static void wolfCLU_CRLVerifyHelp(void)
"-outform pem or der out format");
WOLFCLU_LOG(WOLFCLU_L0,
"-out output file to write to\n"
"-noout do not print output if set");
"-noout do not print output if set\n"
"-text output human readable text of CRL");
}
#endif

Expand All @@ -63,6 +65,7 @@ int wolfCLU_CRLVerify(int argc, char** argv)
int inForm = PEM_FORM;
int outForm = PEM_FORM;
int output = 1;
int text = 0;
int longIndex = 1;
int option;
byte* der = NULL;
Expand All @@ -71,6 +74,7 @@ int wolfCLU_CRLVerify(int argc, char** argv)
char* out = NULL;
WOLFSSL_BIO* bioIn = NULL;
WOLFSSL_BIO* bioOut = NULL;
WOLFSSL_X509_CRL* test;

opterr = 0; /* do not display unrecognized options */
optind = 0; /* start at indent 0 */
Expand Down Expand Up @@ -102,6 +106,10 @@ int wolfCLU_CRLVerify(int argc, char** argv)
caCert = optarg;
break;

case WOLFCLU_TEXT_OUT:
text = 1;
break;

case WOLFCLU_NOOUT:
output = 0;
break;
Expand Down Expand Up @@ -175,18 +183,13 @@ int wolfCLU_CRLVerify(int argc, char** argv)
}
}

test = wolfSSL_d2i_X509_CRL(NULL, der, derSz);
/* sanity check that input is indeed a CRL */
if (ret == WOLFCLU_SUCCESS) {
WOLFSSL_X509_CRL* test;

test = wolfSSL_d2i_X509_CRL(NULL, der, derSz);
if (test == NULL) {
wolfCLU_LogError("Unable to parse CRL file");
ret = WOLFCLU_FATAL_ERROR;
}
else {
wolfSSL_X509_CRL_free(test);
}
}


Expand Down Expand Up @@ -216,6 +219,28 @@ int wolfCLU_CRLVerify(int argc, char** argv)
}
}

if (ret == WOLFCLU_SUCCESS && text != 0) {
#ifndef NO_WOLFSSL_CRL_PRINT
/* set to stdout if no output is set */
if (bioOut == NULL) {
bioOut = wolfSSL_BIO_new(wolfSSL_BIO_s_file());
if (bioOut == NULL) {
ret = WOLFCLU_FATAL_ERROR;
}
else {
if (wolfSSL_BIO_set_fp(bioOut, stdout, BIO_NOCLOSE)
!= WOLFSSL_SUCCESS) {
ret = WOLFCLU_FATAL_ERROR;
}
}
}
wolfSSL_X509_CRL_print(bioOut, test);
#else
wolfCLU_LogError("CRL print not available in version of wolfSSL");
ret = WOLFCLU_FATAL_ERROR;
#endif
}

if (ret == WOLFCLU_SUCCESS && output != 0) {
if (outForm == DER_FORM) {
wolfSSL_BIO_write(bioOut, der, derSz);
Expand Down Expand Up @@ -263,6 +288,7 @@ int wolfCLU_CRLVerify(int argc, char** argv)
if (der != NULL) {
XFREE(der, HEAP_HINT, DYNAMIC_TYPE_CRL);
}
wolfSSL_X509_CRL_free(test);
wolfSSL_BIO_free(bioIn);
wolfSSL_BIO_free(bioOut);
return ret;
Expand Down
13 changes: 13 additions & 0 deletions tests/x509/CRL-verify-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ if [ -f "test.crl.pem" ]; then
exit 99
fi

RESULT=`./wolfssl crl -in certs/crl.pem -text`
echo $RESULT | grep "CRL print not available in version of wolfSSL"
if [ $? == 0 ]; then
# check the CRL -text arg
run_success "crl -noout -in ./certs/crl.pem -text"
echo $RESULT | grep "Certificate Revocation List (CRL):"
if [ $? != 0 ]; then
echo $RESULT
echo "Couldn't find expected output"
exit 99
fi
fi

echo "Done"
exit 0