Title: tls: server getPeerCertificate(true) drops the peer certificate chain since v26.8.0 (regressed by #64677) · Issue #65579 · nodejs/node · GitHub
Open Graph Title: tls: server getPeerCertificate(true) drops the peer certificate chain since v26.8.0 (regressed by #64677) · Issue #65579 · nodejs/node
X Title: tls: server getPeerCertificate(true) drops the peer certificate chain since v26.8.0 (regressed by #64677) · Issue #65579 · nodejs/node
Description: Version v26.8.0 and up. v26.7.0 is unaffected. Reproduces on current main. Platform Linux 6.18.35.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC x86_64 GNU/Linux Also reproduced on GitHub Actions ubuntu-latest. OpenSSL is 3.5.7. Subsys...
Open Graph Description: Version v26.8.0 and up. v26.7.0 is unaffected. Reproduces on current main. Platform Linux 6.18.35.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC x86_64 GNU/Linux Also reproduced on GitHub Actions...
X Description: Version v26.8.0 and up. v26.7.0 is unaffected. Reproduces on current main. Platform Linux 6.18.35.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC x86_64 GNU/Linux Also reproduced on GitHub Actions...
Opengraph URL: https://github.com/nodejs/node/issues/65579
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tls: server getPeerCertificate(true) drops the peer certificate chain since v26.8.0 (regressed by #64677)","articleBody":"### Version\n\n`v26.8.0` and up. `v26.7.0` is unaffected. Reproduces on current `main`.\n\n### Platform\n\n```text\nLinux 6.18.35.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC x86_64 GNU/Linux\n```\n\nAlso reproduced on GitHub Actions `ubuntu-latest`. OpenSSL is 3.5.7.\n\n### Subsystem\n\ntls\n\n### What steps will reproduce the bug?\n\nOn the server side of a mutual-TLS connection, `socket.getPeerCertificate(true)` no longer returns the client certificate's issuer chain. The leaf is returned fully populated, but `issuerCertificate` is `undefined`, even though the client presented `[leaf, intermediate]` and the socket is `authorized`.\n\nHere is a repo script that creates a root -> intermediate -> client chain with `openssl`, then runs a `node:https` mTLS handshake and reads the peer certificate on the server:\n\n```js\nimport https from 'node:https';\nimport { execFileSync } from 'node:child_process';\nimport { mkdtempSync, writeFileSync, readFileSync, rmSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\n// Generate root CA -> intermediate CA -> client leaf and server cert\nconst dir = mkdtempSync(join(tmpdir(), 'mtls-'));\nconst f = (n) => join(dir, n);\nconst openssl = (...a) => execFileSync('openssl', a, { stdio: 'ignore' });\nconst ec = ['-newkey', 'ec', '-pkeyopt', 'ec_paramgen_curve:prime256v1', '-nodes'];\n\nopenssl('req', '-x509', ...ec, '-keyout', f('root.key'), '-out', f('root.crt'),\n '-days', '2', '-subj', '/CN=Repro Root CA', '-addext', 'basicConstraints=critical,CA:TRUE');\n\nwriteFileSync(f('int.ext'), 'basicConstraints=critical,CA:TRUE,pathlen:0\\nkeyUsage=critical,keyCertSign,cRLSign\\n');\nopenssl('req', ...ec, '-keyout', f('int.key'), '-out', f('int.csr'), '-subj', '/CN=Repro Intermediate CA');\nopenssl('x509', '-req', '-in', f('int.csr'), '-CA', f('root.crt'), '-CAkey', f('root.key'),\n '-CAcreateserial', '-days', '2', '-extfile', f('int.ext'), '-out', f('int.crt'));\n\nwriteFileSync(f('leaf.ext'), 'basicConstraints=critical,CA:FALSE\\nkeyUsage=critical,digitalSignature\\nextendedKeyUsage=clientAuth\\n');\nopenssl('req', ...ec, '-keyout', f('leaf.key'), '-out', f('leaf.csr'), '-subj', '/CN=Repro Client');\nopenssl('x509', '-req', '-in', f('leaf.csr'), '-CA', f('int.crt'), '-CAkey', f('int.key'),\n '-CAcreateserial', '-days', '2', '-extfile', f('leaf.ext'), '-out', f('leaf.crt'));\n\nopenssl('req', '-x509', ...ec, '-keyout', f('srv.key'), '-out', f('srv.crt'),\n '-days', '2', '-subj', '/CN=localhost', '-addext', 'subjectAltName=DNS:localhost');\n\nconst root = readFileSync(f('root.crt'));\nconst clientChain = Buffer.concat([readFileSync(f('leaf.crt')), readFileSync(f('int.crt'))]);\n\nconst server = https.createServer(\n { key: readFileSync(f('srv.key')), cert: readFileSync(f('srv.crt')), ca: [root],\n requestCert: true, rejectUnauthorized: false },\n (req, res) => {\n const cert = req.socket.getPeerCertificate(true);\n console.log('node', process.version, '| authorized:', req.socket.authorized,\n '| issuerCertificate present:', !!cert.issuerCertificate);\n res.writeHead(200); res.end('x');\n });\nserver.listen(0, 'localhost', () => {\n const req = https.request(\n { hostname: 'localhost', port: server.address().port,\n key: readFileSync(f('leaf.key')), cert: clientChain, ca: [root], rejectUnauthorized: false },\n (res) => { res.resume(); res.on('end', () => { server.close(); rmSync(dir, { recursive: true, force: true }); }); });\n req.end();\n});\n```\n\nCompare output on an affected and an unaffected version:\n\n```\n$ node-v26.7.0 repro.mjs\nnode v26.7.0 | authorized: true | issuerCertificate present: true\n$ node-v26.8.1 repro.mjs\nnode v26.8.1 | authorized: true | issuerCertificate present: false\n```\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time on Node >= 26.8.0. Requires `requestCert: true`, a client certificate signed through at least one intermediate, and reading the chain with `getPeerCertificate(true)` or `getPeerCertificate` with `includeChain`.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`getPeerCertificate(true)` on the server should return the leaf with an `issuerCertificate` property linking to the intermediate (and so on up the chain), as it did through v26.7.0 and as [documented](https://nodejs.org/api/tls.html#tlssocketgetpeercertificatedetailed): \"If the full certificate chain was requested, each certificate will include an `issuerCertificate` property containing an object representing its issuer's certificate.\"\n\n### What do you see instead?\n\nThe leaf is returned fully populated (subject, issuer, `raw`, fingerprints, etc.) but `issuerCertificate` is `undefined`. `getPeerX509Certificate().issuerCertificate` is also absent.\n\n### Additional information\n\nI bisected nightly builds and `v27.0.0-nightly20260808` (`aed4eaf89d`) is the last one before the break; `v27.0.0-nightly20260809` (`0700e749eb`) is where it breaks. The only tls/crypto commit in that range is c59cd6b04 (#64677), \"tls: fix authorized state on no-cert TLS1.3 client cert resumption\", which added to `onServerSocketSecure()` in `lib/internal/tls/wrap.js`.\n\nCalling `getPeerX509Certificate()` caches the peer certificate as a leaf only, so subsequent `getPeerCertificate(true)` returns the cached leaf only.\n\nThe underlying issue is really a caching interaction that predates #64677, which is that calling `getPeerX509Certificate()` poisons `getPeerCertificate(true)`. It can be reproduced on the unaffected versios by inserting that call before reading the chain, i.e., insert `req.socket.getPeerX509Certificate();` as the first line of the request handler in the repro above. #64677 tripped this by calling `getPeerX509Certificate()` internally.\n\nThere are sort of two issues here AFAICT: the caching interaction where `getPeerX509Certificate()` mutates the chain for a later `getPeerCertificate(true)`, and #64677 using `getPeerX509Certificate()` just to test presence of a peer certificate (instead of a check that does not populate/replace the cached peer certificate).\n\nThis regression affects any server that inspects the client certificate chain on Node >= 26.8.0.","author":{"url":"https://github.com/tgies","@type":"Person","name":"tgies"},"datePublished":"2026-08-27T09:47:45Z","url":"https://github.com/nodejs/node/issues/65579"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2ed3cbe9-c93d-46ff-99be-28efd1d0f5ff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CAA6:1C7D35:8DA0ED:BC5FC9:6AED2AA3 |
| html-safe-nonce | 5f7b60ae5fbd3725afd09a31c0f8355ad6e4607fb4c21e3fa954ccc8c293024f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQUE2OjFDN0QzNTo4REEwRUQ6QkM1RkM5OjZBRUQyQUEzIiwidmlzaXRvcl9pZCI6Ijg2NDE2NTA1MjU4OTg3NzkyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d41b3a30b80ce57cd6c9dc00e253576a03514d5c15a91e34e8874a0deff63a22 |
| hovercard-subject-tag | issue:5266181486 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/65579/issue_layout |
| twitter:image | https://opengraph.githubassets.com/44ef0bdb93865f5499f373ec0f6ec0a7a8f3417820c0ad226d30e6e332305478/nodejs/node/issues/65579 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/44ef0bdb93865f5499f373ec0f6ec0a7a8f3417820c0ad226d30e6e332305478/nodejs/node/issues/65579 |
| og:image:alt | Version v26.8.0 and up. v26.7.0 is unaffected. Reproduces on current main. Platform Linux 6.18.35.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC x86_64 GNU/Linux Also reproduced on GitHub Actions... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tgies |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 98b41fa4b5635ceb45a4c54320fced73817ff290 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width