Title: tls: TLSSocket session deserialization failure leaves errors on the OpenSSL error queue (wrong error codes in later crypto calls) · Issue #67204 · nodejs/node · GitHub
Open Graph Title: tls: TLSSocket session deserialization failure leaves errors on the OpenSSL error queue (wrong error codes in later crypto calls) · Issue #67204 · nodejs/node
X Title: tls: TLSSocket session deserialization failure leaves errors on the OpenSSL error queue (wrong error codes in later crypto calls) · Issue #67204 · nodejs/node
Description: Version: v26.13.0 (also v24.22.2) Platform: macOS arm64; OpenSSL 3.5.9 What steps will reproduce the bug? // repro.mjs — run: node repro.mjs import tls from 'node:tls'; import crypto from 'node:crypto'; const badPem = '-----BEGIN PRIVATE...
Open Graph Description: Version: v26.13.0 (also v24.22.2) Platform: macOS arm64; OpenSSL 3.5.9 What steps will reproduce the bug? // repro.mjs — run: node repro.mjs import tls from 'node:tls'; import crypto from 'node:cry...
X Description: Version: v26.13.0 (also v24.22.2) Platform: macOS arm64; OpenSSL 3.5.9 What steps will reproduce the bug? // repro.mjs — run: node repro.mjs import tls from 'node:tls'; import crypto from &...
Opengraph URL: https://github.com/nodejs/node/issues/67204
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tls: TLSSocket session deserialization failure leaves errors on the OpenSSL error queue (wrong error codes in later crypto calls)","articleBody":"\n**Version:** v26.13.0 (also v24.22.2)\n**Platform:** macOS arm64; OpenSSL 3.5.9\n\n**What steps will reproduce the bug?**\n\n```js\n// repro.mjs — run: node repro.mjs\nimport tls from 'node:tls';\nimport crypto from 'node:crypto';\nconst badPem = '-----BEGIN PRIVATE KEY-----\\nAAAA\\n-----END PRIVATE KEY-----';\nconst code = () => { try { crypto.createPrivateKey(badPem); } catch (e) { return e.code; } };\nconsole.log('before:', code()); // ERR_OSSL_UNSUPPORTED\nconst session = Buffer.from(\n '006e6f64656a733a746c733a73657373696f6e3a31000014676174657761792e6578616d706c652e746573746d6f636b65642073657373696f6e',\n 'hex',\n);\nconst socket = tls.connect({ host: '127.0.0.1', port: 9, servername: 'gateway.example.test', session });\nsocket.on('error', () => {});\nsocket.destroy();\nconsole.log('after: ', code()); // ERR_OSSL_ASN1_TOO_LONG (error left by d2i_SSL_SESSION)\n```\n\n**What is the expected behavior?** The same error code before and after. A session that cannot be deserialized should not leave errors on the OpenSSL error queue.\n\n**What do you see instead?** `after: ERR_OSSL_ASN1_TOO_LONG`. The leftover error from `d2i_SSL_SESSION` is reported by an unrelated call.\n\n**Additional information**\n\n- Follow-up of #67203, as suggested there. The abort itself is fixed by ae35a8fe801f6487e5737d93516536f1d8f514a2.\n- `TLSWrap::SetSession` → `GetTLSSession` → `d2i_SSL_SESSION` does not clear or pop the error queue on failure (`// TODO(tniessen): figure out error handling`). Using `ClearErrorOnReturn` there, or throwing `ERR_TLS_INVALID_SESSION`, would avoid it.\n- Seen in practice with a test HTTP interceptor that emits fake TLS sessions (mswjs/interceptors#892), which undici then reuses.\n","author":{"url":"https://github.com/webteamfrit","@type":"Person","name":"webteamfrit"},"datePublished":"2026-11-02T18:28:59Z","url":"https://github.com/nodejs/node/issues/67204"}
| 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:d13db48d-d58c-1937-2ddf-7f819da11113 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A4EC:26863A:663202:848D38:6AED2CA9 |
| html-safe-nonce | a0fd9f8299d01cdc2fea047814d687328a2d8913fad859783ba483de199d54c2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNEVDOjI2ODYzQTo2NjMyMDI6ODQ4RDM4OjZBRUQyQ0E5IiwidmlzaXRvcl9pZCI6Ijg4MDk2OTY2NTg2MDIxNDI4ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cd5fe044eb1f85924d97e4c9c76c22336b42c155edac435403f9d776579eadce |
| hovercard-subject-tag | issue:6168555052 |
| 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/67204/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e9951f3db9a923cf99900d3f41c9bcea999f7745342e02b6e4f4fd0f161851b2/nodejs/node/issues/67204 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e9951f3db9a923cf99900d3f41c9bcea999f7745342e02b6e4f4fd0f161851b2/nodejs/node/issues/67204 |
| og:image:alt | Version: v26.13.0 (also v24.22.2) Platform: macOS arm64; OpenSSL 3.5.9 What steps will reproduce the bug? // repro.mjs — run: node repro.mjs import tls from 'node:tls'; import crypto from 'node:cry... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | webteamfrit |
| hostname | github.com |
| expected-hostname | github.com |
| None | e51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a |
| 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 | 59ebb7b901cc154ecc179a44f266fcf69f343b30 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width