@@ -278,6 +278,64 @@ if ./wolfssl ca -help 2>&1 | grep altextend &> /dev/null; then
278278 rm -f tmp-server-chimera-cert.pem
279279fi
280280
281+ # Test path concatenation fix for -out with new_certs_dir
282+ echo " Testing -out path handling with new_certs_dir"
283+ mkdir -p outdir-test/certs
284+ cat << EOF > ca-outdir.conf
285+ [ ca ]
286+ default_ca = CA_default
287+
288+ [ CA_default ]
289+ dir = ./certs
290+ database = ./index.txt
291+ new_certs_dir = ./outdir-test/certs
292+ certificate = \$ dir/ca-cert.pem
293+ private_key = \$ dir/ca-key.pem
294+ rand_serial = yes
295+ default_days = 365
296+ default_md = sha256
297+ policy = policy_any
298+
299+ [ policy_any ]
300+ countryName = supplied
301+ stateOrProvinceName = optional
302+ organizationName = optional
303+ organizationalUnitName = optional
304+ commonName = supplied
305+ emailAddress = optional
306+ EOF
307+
308+ rm index.txt
309+ touch index.txt
310+ run_success " req -key ./certs/server-key.pem -subj /O=wolfSSL/C=US/ST=MT/L=Bozeman/CN=wolfSSL/OU=org-unit -out tmp-outdir.csr"
311+
312+ # Test 1: absolute -out path should override new_certs_dir
313+ ABS_OUT_PATH=" $( pwd) /outdir-test/absolute-out.pem"
314+ run_success " ca -config ca-outdir.conf -in tmp-outdir.csr -out $ABS_OUT_PATH "
315+ if [ ! -f " $ABS_OUT_PATH " ]; then
316+ echo " Absolute -out path test failed: file not found at $ABS_OUT_PATH "
317+ exit 99
318+ fi
319+ if [ -f ./outdir-test/certs" $ABS_OUT_PATH " ]; then
320+ echo " Absolute -out path test failed: file incorrectly concatenated"
321+ exit 99
322+ fi
323+ echo " Absolute -out path test passed"
324+
325+ # Test 2: relative -out path should be appended to new_certs_dir
326+ rm index.txt
327+ touch index.txt
328+ run_success " ca -config ca-outdir.conf -in tmp-outdir.csr -out relative-out.pem"
329+ if [ ! -f ./outdir-test/certs/relative-out.pem ]; then
330+ echo " Relative -out path test failed: file not found at ./outdir-test/certs/relative-out.pem"
331+ exit 99
332+ fi
333+ echo " Relative -out path test passed"
334+
335+ rm -rf outdir-test
336+ rm -f ca-outdir.conf
337+ rm -f tmp-outdir.csr
338+
281339rm -f test_ca.pem
282340rm -f tmp.pem
283341rm -f rand-file-test
0 commit comments