Skip to content

Commit

Permalink
fixup! Implement wolfSSL_X509_STORE_set_default_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
julek-wolfssl committed Jan 3, 2025
1 parent 341ed32 commit cd73893
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/x509_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,8 @@ static int X509StoreLoadFile(WOLFSSL_X509_STORE *str,
static_buffer_init(&content, stackBuffer, FILE_BUFFER_SIZE);
#endif

WOLFSSL_MSG_EX("X509StoreLoadFile: Loading file: %s", fname);

ret = X509StoreReadFile(fname, &content, &contentLen, &type);
if (ret != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("Failed to load file");
Expand Down Expand Up @@ -1682,8 +1684,10 @@ int wolfSSL_X509_STORE_set_default_paths(WOLFSSL_X509_STORE *str)
char* certDir = NULL;
char* certFile = NULL;

certDir = wc_strdup_ex(XGETENV("SSL_CERT_DIR"), DYNAMIC_TYPE_TMP_BUFFER);
WOLFSSL_ENTER("wolfSSL_X509_STORE_set_default_paths");

certFile = wc_strdup_ex(XGETENV("SSL_CERT_FILE"), DYNAMIC_TYPE_TMP_BUFFER);
certDir = wc_strdup_ex(XGETENV("SSL_CERT_DIR"), DYNAMIC_TYPE_TMP_BUFFER);

ret = wolfSSL_X509_STORE_load_locations(str, certFile, certDir);

Expand Down
8 changes: 8 additions & 0 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -62369,6 +62369,14 @@ static int test_wolfSSL_X509_STORE_load_locations(void)
ExpectIntEQ(X509_STORE_load_locations(store, NULL, certs_path),
WOLFSSL_SUCCESS);

#if defined(XGETENV) && !defined(NO_GETENV)
ExpectIntEQ(wolfSSL_CTX_UnloadCAs(ctx), WOLFSSL_SUCCESS);
/* Test with env vars */
ExpectIntEQ(setenv("SSL_CERT_FILE", client_pem_file, 1), 0);
ExpectIntEQ(setenv("SSL_CERT_DIR", certs_path, 1), 0);
ExpectIntEQ(X509_STORE_set_default_paths(store), WOLFSSL_SUCCESS);
#endif

#if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
/* Clear nodes */
ERR_clear_error();
Expand Down

0 comments on commit cd73893

Please sign in to comment.