test: send SNI in CA certificate test

Set servername when connecting to www.nodejs.org so the server selects
its certificate for that hostname. Without SNI, it returns a certificate
that does not cover www.nodejs.org, and the test fails before exercising
CA handling. The nightly internet test is failing with this error [1].

Reproduce the certificate mismatch without Node.js:

    openssl s_client -connect www.nodejs.org:443 -noservername \
      -verify_hostname www.nodejs.org -verify_return_error </dev/null

This reports "verify error:num=62:Hostname mismatch". Replacing
-noservername with -servername www.nodejs.org succeeds.

[1]: https://github.com/nodejs/node/actions/runs/39084453901

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66835
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
Tamir Duberstein authored and GitHub committed 2026-10-22 12:58:43 +00:00
1 parent 6209c29dcf
commit 727e0cac72
1 file changed
+1
+1
View File
@@ -23,6 +23,7 @@ const caCert = loadPEM('ca1-cert');
const opts = {
host: 'www.nodejs.org',
servername: 'www.nodejs.org',
port: 443,
rejectUnauthorized: true,
};