Skip to content

Commit 88127b9

Browse files
committed
Recognize Windows drive-letter paths as absolute, enable more tests
- Check for drive-letter (X:) and backslash (\) paths as absolute in ca -out handling, matching OpenSSL's ossl_is_absolute_path() logic with #ifdef _WIN32 guard - Add Windows-specific tests for drive-letter and backslash absolute paths in TestCAOutdirPath - Enable WOLFSSL_DUAL_ALG_CERTS for chimera/altextend CA tests - Fix MSVC VLA error: use #define for LARGE_TEMP_SZ instead of const int (MSVC requires compile-time constant for array sizes) - Replace CSR attributes test: use new attributes-supported-csr.pem with only wolfSSL-supported attributes (challengePassword, unstructuredName), add test asserting unsupported attributes fail
1 parent 943ecbd commit 88127b9

5 files changed

Lines changed: 76 additions & 21 deletions

File tree

certs/attributes-supported-csr.pem

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-----BEGIN CERTIFICATE REQUEST-----
2+
MIIC0TCCAbkCAQAwVzELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB01vbnRhbmExEDAO
3+
BgNVBAcMB0JvemVtYW4xEDAOBgNVBAoMB3dvbGZTU0wxEjAQBgNVBAMMCWF0dHJf
4+
dGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMCVCOFXQfJxbbfS
5+
RUEnAWXGRa7yvCQwuJXOL07W9hyIvHyf+6hnf/5cnFF194rKB+c1L4/hvXvAL3yr
6+
ZKgX/Mpde7rgIeVyLm8uhtiVc9qsG1O5Xz/XGQ0lT+FjY1GLC2Q/rUO4pRxcNLOu
7+
AKBjxfZ/C1loeHOmjBipAm2vwxkBLrgQ48bMQLRpo0YzaYduxLsXpvPo3a1zvHsv
8+
IbX9ZlEMvVSz4W1fHLwjc9EJA4kU0hC5ZMMq0KGWSrzh1Bpbx6DAwWN4D0Q3MDKW
9+
gDIjlaF3uhPSl3PiXSXJag3DOWCktLBpQkIJ6dgIvDMgs1gip6rrxOHmYYPF0pbf
10+
2dBPrdcCAwEAAaA1MBYGCSqGSIb3DQEJBzEJDAd0ZXN0MTIzMBsGCSqGSIb3DQEJ
11+
AjEODAx3b2xmU1NMX3Rlc3QwDQYJKoZIhvcNAQELBQADggEBAHpkAc/Kr2gZ3KwX
12+
L0Rm8eTlEYIydRcWDRmrqNedMnZ4jZnQxjq6oOBGIYaafi+HfmZaEVqziwhSsR/H
13+
n9lu6t6k9biD17SyLIh9oDaDB3QXCyUTgzZN8FvuRz3cTTDiZL0gCIR948bitS3F
14+
PPW10W8Z4wir50eUPmt4mlVciIm+BCU4uDr1cUNdbWC3M+4KCh3m3vASgzba76Ya
15+
y4akoukLPsbdz2ub0x9A1i3x1lao+HQ7JjFNo9pDsty9gmDgrOOfusm9f6AGV4c7
16+
n5fsDxCKeHvPHofgZUGvqTsSECM15U2dcJQJcUNV0qslIK9r9ewpJa6tfTWk/EL8
17+
+JTPLho=
18+
-----END CERTIFICATE REQUEST-----

ide/winvs/user_settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#define WOLFSSL_SHAKE256
3535
#define HAVE_DILITHIUM
3636
#define WOLFSSL_WC_DILITHIUM
37+
#define WOLFSSL_EXPERIMENTAL_SETTINGS
38+
#define WOLFSSL_DUAL_ALG_CERTS
3739

3840
#define HAVE_TLS_EXTENSIONS
3941
#define HAVE_SNI

src/x509/clu_x509_sign.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,12 @@ int wolfCLU_GenChimeraCertSign(WOLFSSL_BIO *bioCaKey, WOLFSSL_BIO *bioAltCaKey,
257257
const char *altSigAlgOid = "2.5.29.73";
258258
const char *altSigValOid = "2.5.29.74";
259259

260-
/*
261-
* LARGE_TEMO_SZ defines the size of temporary buffers used for signature key,
260+
/*
261+
* LARGE_TEMP_SZ defines the size of temporary buffers used for signature key,
262262
* verification key and signature value buffers.
263263
* The value 11264 is enough for P-521 and ML-DSA-87 PEM certs.
264264
*/
265-
const int LARGE_TEMP_SZ = 11264;
265+
#define LARGE_TEMP_SZ 11264
266266
byte caKeyBuf[LARGE_TEMP_SZ];
267267
int caKeySz = LARGE_TEMP_SZ;
268268
byte altCaKeyBuf[LARGE_TEMP_SZ];
@@ -1045,8 +1045,13 @@ int wolfCLU_CertSignAppendOut(WOLFCLU_CERT_SIGN* csign, char* out)
10451045
if (ret == WOLFCLU_SUCCESS && csign->outDir != NULL && out != NULL) {
10461046
int currentSz = (int)XSTRLEN(csign->outDir);
10471047

1048-
/* If out is an absolute path, use it directly instead of appending */
1049-
if (out[0] == '/') {
1048+
/* If out is an absolute path, use it directly instead of appending.
1049+
* Matches OpenSSL's ossl_is_absolute_path() behaviour. */
1050+
if (out[0] == '/'
1051+
#ifdef _WIN32
1052+
|| out[0] == '\\' || (out[0] != '\0' && out[1] == ':')
1053+
#endif
1054+
) {
10501055
s = (char*)XMALLOC(outSz + 1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
10511056
if (s == NULL) {
10521057
ret = MEMORY_E;

tests/x509/x509-ca-test.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,6 @@ def setUp(self):
749749
def tearDown(self):
750750
_cleanup(self.conf, self.csr, _tmp("index.txt"), self.outdir)
751751

752-
@unittest.skipIf(sys.platform == "win32",
753-
"wolfSSL does not recognize drive-letter paths as absolute")
754752
def test_absolute_out_path(self):
755753
"""Absolute -out path should override new_certs_dir."""
756754
abs_out = (self.outdir + "/absolute-out.pem")
@@ -765,6 +763,34 @@ def test_absolute_out_path(self):
765763
# The file at the absolute location is the correct one;
766764
# just verify it was created (already checked above).
767765

766+
@unittest.skipUnless(sys.platform == "win32", "Windows drive-letter test")
767+
def test_absolute_drive_letter_out_path(self):
768+
"""On Windows, drive-letter paths (C:\\...) are treated as absolute."""
769+
import tempfile
770+
abs_out = os.path.join(tempfile.gettempdir(),
771+
"wolfclu_test_abs.pem").replace("\\", "/")
772+
self.addCleanup(lambda: _cleanup(abs_out))
773+
774+
r = run_wolfssl("ca", "-config", self.conf,
775+
"-in", self.csr, "-out", abs_out)
776+
self.assertEqual(r.returncode, 0, r.stderr)
777+
self.assertTrue(os.path.isfile(abs_out),
778+
"File not found at {}".format(abs_out))
779+
780+
@unittest.skipUnless(sys.platform == "win32", "Windows backslash test")
781+
def test_absolute_backslash_out_path(self):
782+
"""On Windows, backslash paths (\\\\...) are treated as absolute."""
783+
import tempfile
784+
abs_out = os.path.join(tempfile.gettempdir(),
785+
"wolfclu_test_abs_bs.pem")
786+
self.addCleanup(lambda: _cleanup(abs_out))
787+
788+
r = run_wolfssl("ca", "-config", self.conf,
789+
"-in", self.csr, "-out", abs_out)
790+
self.assertEqual(r.returncode, 0, r.stderr)
791+
self.assertTrue(os.path.isfile(abs_out),
792+
"File not found at {}".format(abs_out))
793+
768794
def test_relative_out_path(self):
769795
"""Relative -out path should be appended to new_certs_dir."""
770796
_cleanup(_tmp("index.txt"))

tests/x509/x509-req-test.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -654,26 +654,30 @@ def test_long_country_code_fails(self):
654654
class TestReqCSRAttributes(unittest.TestCase):
655655
"""Test CSR attribute printing."""
656656

657-
def test_attributes_csr(self):
658-
"""req -text on attributes-csr.pem shows expected attributes."""
659-
csr_path = os.path.join(CERTS_DIR, "attributes-csr.pem")
657+
def test_supported_attributes(self):
658+
"""req -text on a CSR with supported attributes shows them."""
659+
csr_path = os.path.join(CERTS_DIR, "attributes-supported-csr.pem")
660660
if not os.path.isfile(csr_path):
661-
self.skipTest("attributes-csr.pem not available")
661+
self.skipTest("attributes-supported-csr.pem not available")
662662

663663
r = run_wolfssl("req", "-text", "-noout", "-in", csr_path)
664-
if r.returncode != 0:
665-
self.skipTest("wolfSSL version does not support CSR attributes")
664+
self.assertEqual(r.returncode, 0, r.stderr)
666665

667666
output = r.stdout
668-
self.assertIn("initials", output)
669-
self.assertIn("abc", output)
670-
self.assertIn("dnQualifier", output)
671-
self.assertIn("dn", output)
672667
self.assertIn("challengePassword", output)
673-
self.assertIn("test", output)
674-
self.assertIn("givenName", output)
675-
self.assertIn("Given Name", output)
676-
self.assertIn("surname", output)
668+
self.assertIn("test123", output)
669+
self.assertIn("unstructuredName", output)
670+
self.assertIn("wolfSSL_test", output)
671+
672+
def test_unsupported_attributes_fail(self):
673+
"""req -text on a CSR with unsupported attributes should fail."""
674+
csr_path = os.path.join(CERTS_DIR, "attributes-csr.pem")
675+
if not os.path.isfile(csr_path):
676+
self.skipTest("attributes-csr.pem not available")
677+
678+
r = run_wolfssl("req", "-text", "-noout", "-in", csr_path)
679+
self.assertNotEqual(r.returncode, 0,
680+
"CSR with unsupported attributes should fail")
677681

678682

679683
class TestReqCSRVersion(unittest.TestCase):

0 commit comments

Comments
 (0)