Skip to content

Commit a2437e4

Browse files
committed
Fix client test to check for certificate instead of exit code
s_client may return non-zero when peer verification fails (no CA bundle loaded), but the connection still succeeds and the server certificate is printed to stdout. Assert on the certificate being present rather than requiring exit code 0.
1 parent 6ab8cd2 commit a2437e4

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

tests/client/client-test.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,18 @@ def test_s_client_x509(self):
2929
self.addCleanup(lambda: os.remove(tmp_crt)
3030
if os.path.exists(tmp_crt) else None)
3131

32-
# Run s_client with empty stdin so it connects then disconnects
33-
try:
34-
s_client = subprocess.run(
35-
[WOLFSSL_BIN, "s_client", "-connect", "www.google.com:443"],
36-
input=b"\n",
37-
capture_output=True,
38-
timeout=30,
39-
)
40-
except (subprocess.TimeoutExpired, OSError):
41-
self.skipTest("s_client connection timed out or failed")
42-
43-
if s_client.returncode != 0 or not s_client.stdout:
44-
self.skipTest("s_client could not connect (no network?)")
32+
# Run s_client with empty stdin so it connects then disconnects.
33+
# Verification may fail without a CA bundle, but the connection
34+
# still succeeds and the server certificate is printed to stdout.
35+
s_client = subprocess.run(
36+
[WOLFSSL_BIN, "s_client", "-connect", "www.google.com:443"],
37+
input=b"\n",
38+
capture_output=True,
39+
timeout=30,
40+
)
41+
42+
self.assertIn(b"-----BEGIN CERTIFICATE-----", s_client.stdout,
43+
f"s_client did not return a certificate: {s_client.stderr}")
4544

4645
# Pipe s_client stdout into x509 to extract the cert as PEM
4746
x509_extract = subprocess.run(

0 commit comments

Comments
 (0)