@@ -7410,6 +7410,9 @@ int test_client_nofail(void* args, cbType cb)
74107410 int sharedCtx = 0;
74117411 int doUdp = 0;
74127412 const char* cipherName1, *cipherName2;
7413+ const char* caFile;
7414+ const char* certFile;
7415+ const char* keyFile;
74137416
74147417 wolfSSL_SetLoggingPrefix("client");
74157418
@@ -7441,6 +7444,23 @@ int test_client_nofail(void* args, cbType cb)
74417444 if (cbf != NULL)
74427445 doUdp = cbf->doUdp;
74437446
7447+ /* Extend test_server_nofail()'s existing certFile/keyFile override
7448+ * pattern (a caller-supplied callback_functions can already replace
7449+ * the server's default cert/key) to this, the client side, and to
7450+ * the CA file as well -- previously this always loaded the hardcoded
7451+ * classical defaults below regardless of what was passed in. */
7452+ caFile = caCertFile;
7453+ certFile = cliCertFile;
7454+ keyFile = cliKeyFile;
7455+ if (cbf != NULL) {
7456+ if (cbf->caPemFile != NULL)
7457+ caFile = cbf->caPemFile;
7458+ if (cbf->certPemFile != NULL)
7459+ certFile = cbf->certPemFile;
7460+ if (cbf->keyPemFile != NULL)
7461+ keyFile = cbf->keyPemFile;
7462+ }
7463+
74447464#ifdef WOLFSSL_ENCRYPTED_KEYS
74457465 wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
74467466#endif
@@ -7452,27 +7472,28 @@ int test_client_nofail(void* args, cbType cb)
74527472 if (doUdp)
74537473 udp_connect(&sockfd, wolfSSLIP, ((func_args*)args)->signal->port);
74547474
7455- if (wolfSSL_CTX_load_verify_locations(ctx, caCertFile, 0) != WOLFSSL_SUCCESS)
7475+ if (wolfSSL_CTX_load_verify_locations(ctx, caFile, 0) !=
7476+ WOLFSSL_SUCCESS)
74567477 {
74577478 /* err_sys("can't load ca file, Please run from wolfSSL home dir");*/
74587479 goto done;
74597480 }
74607481#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
7461- if (!sharedCtx && wolfSSL_CTX_use_certificate_file(ctx, cliCertFile ,
7482+ if (!sharedCtx && wolfSSL_CTX_use_certificate_file(ctx, certFile ,
74627483 CERT_FILETYPE) != WOLFSSL_SUCCESS) {
74637484#else
7464- if (wolfSSL_CTX_use_certificate_file(ctx, cliCertFile ,
7485+ if (wolfSSL_CTX_use_certificate_file(ctx, certFile ,
74657486 CERT_FILETYPE) != WOLFSSL_SUCCESS) {
74667487#endif
74677488 /*err_sys("can't load client cert file, "
74687489 "Please run from wolfSSL home dir");*/
74697490 goto done;
74707491 }
74717492#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
7472- if (!sharedCtx && wolfSSL_CTX_use_PrivateKey_file(ctx, cliKeyFile ,
7493+ if (!sharedCtx && wolfSSL_CTX_use_PrivateKey_file(ctx, keyFile ,
74737494 CERT_FILETYPE) != WOLFSSL_SUCCESS) {
74747495#else
7475- if (wolfSSL_CTX_use_PrivateKey_file(ctx, cliKeyFile ,
7496+ if (wolfSSL_CTX_use_PrivateKey_file(ctx, keyFile ,
74767497 CERT_FILETYPE) != WOLFSSL_SUCCESS) {
74777498#endif
74787499
0 commit comments