Title: tls: crl option only loads first CRL from concatenated PEM bundle · Issue #65576 · nodejs/node · GitHub
Open Graph Title: tls: crl option only loads first CRL from concatenated PEM bundle · Issue #65576 · nodejs/node
X Title: tls: crl option only loads first CRL from concatenated PEM bundle · Issue #65576 · nodejs/node
Description: Version Affects all current versions (tested on v22.x). The bug has been present since the initial implementation. Platform All platforms (the issue is in the C++ TLS layer). Subsystem tls, crypto What steps will reproduce the bug? When ...
Open Graph Description: Version Affects all current versions (tested on v22.x). The bug has been present since the initial implementation. Platform All platforms (the issue is in the C++ TLS layer). Subsystem tls, crypto ...
X Description: Version Affects all current versions (tested on v22.x). The bug has been present since the initial implementation. Platform All platforms (the issue is in the C++ TLS layer). Subsystem tls, crypto ...
Opengraph URL: https://github.com/nodejs/node/issues/65576
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tls: crl option only loads first CRL from concatenated PEM bundle","articleBody":"### Version\n\nAffects all current versions (tested on v22.x). The bug has been present since the initial implementation.\n\n### Platform\n\n```text\nAll platforms (the issue is in the C++ TLS layer).\n```\n\n### Subsystem\n\ntls, crypto\n\n### What steps will reproduce the bug?\n\n When passing a PEM file containing multiple concatenated CRLs to the crl option of tls.createSecureContext() (or https.Agent, tls.connect, etc.), only the first CRL in the PEM bundle is loaded. Subsequent\n CRLs are silently ignored.\n\n This causes UNABLE_TO_GET_CRL errors when verifying certificate chains where different certificates are signed by different CAs, each with their own CRL.\n\nMinimal reproducer:\n```javascript\n const tls = require('node:tls');\n const https = require('node:https');\n\n // A PEM file containing two concatenated CRLs:\n // - CRL for Intermediate CA\n // - CRL for Root CA\n const crlBundle = `-----BEGIN X509 CRL-----\n \u003cintermediate CA CRL>\n -----END X509 CRL-----\n -----BEGIN X509 CRL-----\n \u003croot CA CRL>\n -----END X509 CRL-----`;\n\n const agent = new https.Agent({\n ca: caCertBundle, // works fine with concatenated PEM\n crl: crlBundle, // BUG: only the first CRL is loaded\n rejectUnauthorized: true,\n });\n\n // This fails with: Error: unable to get certificate CRL\n // because the second CRL (root CA) was never loaded into the X509_STORE.\n const res = await fetch('https://example.com', { dispatcher: agent });\n```\n\nSwapping the order of the two CRLs in the PEM bundle changes which CRL is loaded, confirming only the first entry is parsed.\n\n### How often does it reproduce? Is there a required condition?\n\n100% reproducible. The only required condition is that the crl option is a PEM string (or Buffer) containing more than one CRL. If the bundle contains only one CRL, the bug is not observable.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nAll CRLs in a concatenated PEM bundle should be loaded, matching the behavior of the ca option which correctly handles concatenated PEM bundles containing multiple CA certificates.\n\n### What do you see instead?\n\nOnly the first CRL from the PEM bundle is loaded. Verification fails with UNABLE_TO_GET_CRL for any certificate in the chain whose issuer's CRL was not the first entry in the bundle.\n\n### Root cause\n\nIn src/crypto/crypto_tls_certificates.cc (https://github.com/nodejs/node/blob/main/src/crypto/crypto_tls_certificates.cc), the AddCRL function calls PEM_read_bio_X509_CRL once and returns:\n\n```c\n bool AddCRL(Environment* env,\n SSL_CTX* ctx,\n const ncrypto::BIOPointer& bio,\n X509_STORE** cache) {\n if (!bio) return false;\n\n DeleteFnPtr\u003cX509_CRL, X509_CRL_free> crl(\n PEM_read_bio_X509_CRL(bio.get(), nullptr, NoPasswordCallback, nullptr));\n if (!crl) return false;\n\n X509_STORE* cert_store = GetOrCreateOwnedCertStore(env, ctx, cache);\n CHECK_EQ(1, X509_STORE_add_crl(cert_store, crl.get()));\n CHECK_EQ(1,\n X509_STORE_set_flags(\n cert_store, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL));\n return true;\n }\n```\n\n OpenSSL's PEM_read_bio_X509_CRL reads a single PEM block from the BIO and advances the read position. To read all CRLs, the caller must loop until it returns NULL. This is documented in PEM_read(3)\n (https://docs.openssl.org/master/man3/PEM_read/) and is how IMPLEMENT_PEM_read_bio works internally.\n\n The adjacent AddCACertificates function in the same file does this correctly:\n\n```c\n size_t AddCACertificates(Environment* env,\n SSL_CTX* ctx,\n const ncrypto::BIOPointer& bio,\n X509_STORE** cache) {\n if (!bio) return 0;\n\n size_t count = 0;\n while (X509Pointer x509 = X509Pointer(PEM_read_bio_X509_AUX(\n bio.get(), nullptr, NoPasswordCallback, nullptr))) {\n CHECK_EQ(1,\n X509_STORE_add_cert(GetOrCreateOwnedCertStore(env, ctx, cache),\n x509.get()));\n CHECK_EQ(1, SSL_CTX_add_client_CA(ctx, x509.get()));\n count++;\n }\n return count;\n }\n```\n\n### Additional information\n\n - curl --crlfile with the same concatenated PEM bundle works correctly (it loops over all CRLs)\n - The ca option in Node.js handles concatenated PEM bundles correctly (via the while loop in AddCACertificates)\n - The bug has been present since at least 2013 based on git history of the AddCRL function","author":{"url":"https://github.com/zenonhun","@type":"Person","name":"zenonhun"},"datePublished":"2026-08-27T07:15:48Z","url":"https://github.com/nodejs/node/issues/65576"}
| 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:515b591b-08ee-fa50-7250-65d184f65358 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A594:A3A4:9585D0:CACA59:6AED5384 |
| html-safe-nonce | cac064babc4e3fcf6d394592c989a1195b5c035622bc2e0efa5337e4492ff665 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTk0OkEzQTQ6OTU4NUQwOkNBQ0E1OTo2QUVENTM4NCIsInZpc2l0b3JfaWQiOiI5MTQ3Mzg0MjYxNzcyMTM3MzQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d33f7140daad11ea22be256b60fbe75418a5f2100f2181a26f591ea7bdc221d4 |
| hovercard-subject-tag | issue:5264922727 |
| 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/65576/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ced1399191d1ab70d409a1f22949217a795b2bbd7ba473a8c2045808c92f3c02/nodejs/node/issues/65576 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ced1399191d1ab70d409a1f22949217a795b2bbd7ba473a8c2045808c92f3c02/nodejs/node/issues/65576 |
| og:image:alt | Version Affects all current versions (tested on v22.x). The bug has been present since the initial implementation. Platform All platforms (the issue is in the C++ TLS layer). Subsystem tls, crypto ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zenonhun |
| hostname | github.com |
| expected-hostname | github.com |
| None | 56fb42677ae87ed3e64410323d67980aa65d0485568a7858f874e7edfc6d1c11 |
| 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 | 9c9a37e2423ed382cf39f70b5aa4b4858b40a3b0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width