diff --git a/src/x509.c b/src/x509.c index 9c090748f..78b6c520a 100644 --- a/src/x509.c +++ b/src/x509.c @@ -6538,7 +6538,7 @@ const char* wolfSSL_X509_verify_cert_error_string(long err) /* Add directory path that will be used for loading certs and CRLs * which have the .rn name format. - * type may be X509_FILETYPE_PEM or X509_FILETYPE_ASN1. + * type may be WOLFSSL_FILETYPE_PEM or WOLFSSL_FILETYPE_ASN1. * returns WOLFSSL_SUCCESS on successful, otherwise negative or zero. */ int wolfSSL_X509_LOOKUP_add_dir(WOLFSSL_X509_LOOKUP* lookup, const char* dir, long type) @@ -6562,7 +6562,7 @@ int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP* lookup, const char* header = NULL; const char* footer = NULL; - if (type != X509_FILETYPE_PEM) + if (type != WOLFSSL_FILETYPE_PEM) return WS_RETURN_CODE(BAD_FUNC_ARG, (int)WOLFSSL_FAILURE); fp = XFOPEN(file, "rb"); @@ -6799,7 +6799,7 @@ static int x509AddCertDir(WOLFSSL_BY_DIR *ctx, const char *argc, long argl) /* @param **ret return value of the control command */ /* @return WOLFSSL_SUCCESS on successful, othewise WOLFSSL_FAILURE */ /* note: WOLFSSL_X509_L_ADD_STORE and WOLFSSL_X509_L_LOAD_STORE have not*/ -/* yet implemented. It retutns WOLFSSL_NOT_IMPLEMENTED */ +/* yet implemented. It returns WOLFSSL_NOT_IMPLEMENTED */ /* when those control commands are passed. */ int wolfSSL_X509_LOOKUP_ctrl(WOLFSSL_X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret) @@ -6816,7 +6816,7 @@ int wolfSSL_X509_LOOKUP_ctrl(WOLFSSL_X509_LOOKUP *ctx, int cmd, WOLFSSL_SUCCESS : WOLFSSL_FAILURE; break; case WOLFSSL_X509_L_ADD_DIR: - /* store directory loaction to use it later */ + /* store directory location to use it later */ #if !defined(NO_WOLFSSL_DIR) lret = x509AddCertDir(ctx->dirs, argc, argl); #else @@ -7395,7 +7395,7 @@ WOLFSSL_API int wolfSSL_X509_load_crl_file(WOLFSSL_X509_LOOKUP *ctx, return ret; } - if (type == X509_FILETYPE_PEM) { + if (type == WOLFSSL_FILETYPE_PEM) { do { crl = wolfSSL_PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); if (crl == NULL) { @@ -7416,7 +7416,8 @@ WOLFSSL_API int wolfSSL_X509_load_crl_file(WOLFSSL_X509_LOOKUP *ctx, } while(crl == NULL); ret = count; - } else if (type == X509_FILETYPE_ASN1) { + } + else if (type == WOLFSSL_FILETYPE_ASN1) { crl = wolfSSL_d2i_X509_CRL_bio(bio, NULL); if (crl == NULL) { WOLFSSL_MSG("Load crl failed"); diff --git a/tests/api.c b/tests/api.c index 3fa546ef3..9a8127dc6 100644 --- a/tests/api.c +++ b/tests/api.c @@ -50593,7 +50593,7 @@ static int test_wolfSSL_SMIME_write_PKCS7(void) #endif /* !NO_BIO */ /* Test of X509 store use outside of SSL context w/ CRL lookup (ALWAYS - returns 0) */ + * returns 0) */ static int test_X509_STORE_No_SSL_CTX(void) { #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && \ @@ -50601,16 +50601,17 @@ static int test_X509_STORE_No_SSL_CTX(void) (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \ (defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL)) - X509_STORE *store; - X509_STORE_CTX *storeCtx; - X509_CRL *crl; - X509 *ca, *cert; - const char cliCrlPem[] = "./certs/crl/cliCrl.pem"; - const char srvCert[] = "./certs/server-cert.pem"; - const char caCert[] = "./certs/ca-cert.pem"; - const char caDir[] = "./certs/crl/hash_pem/"; - XFILE fp; - X509_LOOKUP *lookup; + X509_STORE * store; + X509_STORE_CTX * storeCtx; + X509_CRL * crl; + X509 * ca; + X509 * cert; + const char cliCrlPem[] = "./certs/crl/cliCrl.pem"; + const char srvCert[] = "./certs/server-cert.pem"; + const char caCert[] = "./certs/ca-cert.pem"; + const char caDir[] = "./certs/crl/hash_pem"; + XFILE fp; + X509_LOOKUP * lookup; printf(testingFmt, "test_X509_STORE_No_SSL_CTX"); @@ -50622,8 +50623,8 @@ static int test_X509_STORE_No_SSL_CTX(void) AssertIntEQ(X509_STORE_add_cert(store, ca), SSL_SUCCESS); /* Add CRL lookup directory to store - NOTE: test uses ./certs/crl/hash_pem/0fdb2da4.r0, which is a copy - of crl.pem */ + * NOTE: test uses ./certs/crl/hash_pem/0fdb2da4.r0, which is a copy + * of crl.pem */ AssertNotNull((lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()))); AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_ADD_DIR, caDir, @@ -50633,7 +50634,7 @@ static int test_X509_STORE_No_SSL_CTX(void) SSL_SUCCESS); /* Add CRL to store NOT containing the verified certificate, which - forces use of the CRL lookup directory */ + * forces use of the CRL lookup directory */ fp = XFOPEN(cliCrlPem, "rb"); AssertTrue((fp != XBADFILE)); AssertNotNull(crl = (X509_CRL *)PEM_read_X509_CRL(fp, (X509_CRL **)NULL, @@ -50648,7 +50649,7 @@ static int test_X509_STORE_No_SSL_CTX(void) AssertIntEQ(X509_STORE_CTX_init(storeCtx, store, cert, NULL), SSL_SUCCESS); /* Perform verification, which should NOT indicate CRL missing due to the - store CM's X509 store pointer being NULL */ + * store CM's X509 store pointer being NULL */ AssertIntNE(X509_verify_cert(storeCtx), CRL_MISSING); X509_CRL_free(crl); @@ -50664,8 +50665,8 @@ static int test_X509_STORE_No_SSL_CTX(void) return 0; } -/* Basically the same test as test_X509_STORE_No_SSL_CTX, but with - * X509_LOOKUP_add_dir and X509_FILETYPE_ASN1. */ +/* Test of X509 store use outside of SSL context w/ CRL lookup, but + * with X509_LOOKUP_add_dir and X509_FILETYPE_ASN1. */ static int test_X509_LOOKUP_add_dir(void) { #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && \ @@ -50676,11 +50677,12 @@ static int test_X509_LOOKUP_add_dir(void) X509_STORE * store; X509_STORE_CTX * storeCtx; X509_CRL * crl; - X509 *ca, * cert; + X509 * ca; + X509 * cert; const char cliCrlPem[] = "./certs/crl/cliCrl.pem"; const char srvCert[] = "./certs/server-cert.pem"; const char caCert[] = "./certs/ca-cert.pem"; - const char caDir[] = "./certs/crl/hash_der/"; + const char caDir[] = "./certs/crl/hash_der"; XFILE fp; X509_LOOKUP * lookup; @@ -50694,8 +50696,8 @@ static int test_X509_LOOKUP_add_dir(void) AssertIntEQ(X509_STORE_add_cert(store, ca), SSL_SUCCESS); /* Add CRL lookup directory to store. - Test uses ./certs/crl/hash_der/0fdb2da4.r0, which is a copy - of crl.der */ + * Test uses ./certs/crl/hash_der/0fdb2da4.r0, which is a copy + * of crl.der */ AssertNotNull((lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()))); @@ -50706,7 +50708,7 @@ static int test_X509_LOOKUP_add_dir(void) SSL_SUCCESS); /* Add CRL to store NOT containing the verified certificate, which - forces use of the CRL lookup directory */ + * forces use of the CRL lookup directory */ fp = XFOPEN(cliCrlPem, "rb"); AssertTrue((fp != XBADFILE)); AssertNotNull(crl = (X509_CRL *)PEM_read_X509_CRL(fp, (X509_CRL **)NULL, @@ -50761,7 +50763,7 @@ static int test_X509_LOOKUP_add_dir(void) AssertIntEQ(X509_STORE_CTX_init(storeCtx, store, cert, NULL), SSL_SUCCESS); /* Now we SHOULD get CRL_MISSING, because we looked for PEM - in dir containing only ASN1/DER. */ + * in dir containing only ASN1/DER. */ AssertIntEQ(X509_verify_cert(storeCtx), CRL_MISSING); X509_CRL_free(crl);