Title: crypto: X509Certificate returns "Bad time value" instead of throwing for an unreadable validity time · Issue #67285 · nodejs/node · GitHub
Open Graph Title: crypto: X509Certificate returns "Bad time value" instead of throwing for an unreadable validity time · Issue #67285 · nodejs/node
X Title: crypto: X509Certificate returns "Bad time value" instead of throwing for an unreadable validity time · Issue #67285 · nodejs/node
Description: Version v26.13.0 (also v26.12.0 and main) Platform Linux ARCH 7.2.14-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 30 Oct 2026 14:32:40 +0000 x86_64 GNU/Linux Subsystem crypto What steps will reproduce the bug? The certificate below is signed by a...
Open Graph Description: Version v26.13.0 (also v26.12.0 and main) Platform Linux ARCH 7.2.14-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 30 Oct 2026 14:32:40 +0000 x86_64 GNU/Linux Subsystem crypto What steps will reproduce the b...
X Description: Version v26.13.0 (also v26.12.0 and main) Platform Linux ARCH 7.2.14-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 30 Oct 2026 14:32:40 +0000 x86_64 GNU/Linux Subsystem crypto What steps will reproduce the b...
Opengraph URL: https://github.com/nodejs/node/issues/67285
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"crypto: X509Certificate returns \"Bad time value\" instead of throwing for an unreadable validity time","articleBody":"### Version\n\nv26.13.0 (also v26.12.0 and `main`)\n\n### Platform\n\n```text\nLinux ARCH 7.2.14-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 30 Oct 2026 14:32:40 +0000 x86_64 GNU/Linux\n```\n\n### Subsystem\n\ncrypto\n\n### What steps will reproduce the bug?\n\nThe certificate below is signed by a test CA; its `notAfter` is a well-formed UTCTime with an invalid hour (`261205994748Z`).\n\n```js\nconst { X509Certificate } = require('node:crypto');\n\nconst pem = `-----BEGIN CERTIFICATE-----\nMIIC5TCCAc2gAwIBAgIBAjANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDDAdUZXN0\nIENBMB4XDTI2MTEwNTIyNDc0OFoXDTI2MTIwNTk5NDc0OFowFjEUMBIGA1UEAwwL\nZXhhbXBsZS5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNayUE\nWSzK683fVdu/NUbXxjf/q6NEspMkAQapmQeWGERAZvs67X+WvnGrNyHVfRnZ1T2m\nkj+mSoRtUFkUsGS1lrQMxurmh2CFszK+U27gZwLCamBZ823kEV5rL9exmSzH7ySV\nLe+IX5IauVEONSaKhvng1iMZyp0wdnHaNiPbfznrz6kjxcA3QeymfN45E3pcxKcN\nL2HvGRRsMmZgK0X3kwOVrr9EBm+tfZtEwcc4NCdA5P2iFKiwGsiCP4UWQiXVpV5l\nrC9WuoY0nBWL+SrpBi/TUPpKezMJt4WhTAUKTd5mJkz4oxfcKs9kgq5AC3cyCFbq\npRXUGFDYn1HGJY0pAgMBAAGjQjBAMB0GA1UdDgQWBBRTRZOBbsiOaLkPQvNbIuca\n5QtLmDAfBgNVHSMEGDAWgBQioYz7xbMnzJE0zuCU33ABjrroEDANBgkqhkiG9w0B\nAQsFAAOCAQEAfCcZz4yPRjXukSTl3dXBEYTWAum8KEUiXpXpFGjMVJVZUp1cPUVz\nDen67I34xJ4EPiu9VAOOtgmPrBX+531h4fCsHiw1frWSwvDKzDEFs413TMSIUbI0\nEWEJeMkrwquPjhFAvzmzuCDr1pdDvLkAc2Bl+IpwaFKiCtTSJ9GRIvn4JDZoCXxB\nuNAQu8DSrkuGjKowpDGutOOGjA5dtp308dU13Ae4WFY4ABoTIjpqu8V6fx85Eucd\nz97SfIMwqcaWPkPWr0bMQwwaTrzYkNYCa+Zy5qk8hx7V1lcBlHBAMRK8NA2t6Ptj\nIh0JzM/oAu6BuPAsmq1FbAkXEiCrvq0V6A==\n-----END CERTIFICATE-----`;\n\nconst x = new X509Certificate(pem);\nconsole.log(x.validTo); // 'Bad time value'\nconsole.log(x.validToDate); // Invalid Date\nconsole.log(x.toLegacyObject().valid_to); // 'Bad time value'\nconsole.log(Date.now() > new Date(x.validTo)); // false\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, for a `notBefore` or `notAfter` that OpenSSL cannot convert to a date.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`validTo`/`validToDate` (and `validFrom`/`validFromDate`) throw, as `subjectAltName` does for a malformed extension since fd3c87ed43.\n\n\n### What do you see instead?\n\n`\"Bad time value\"` and `Invalid Date`, without an error. Comparisons with `Invalid Date` are always `false`, so a check such as\n`Date.now() > new Date(x.validTo)` treats the certificate as not expired.\n\n### Additional information\n\n`X509View::getValidFrom/getValidTo` in `deps/ncrypto/ncrypto.cc` write the string for unprintable times; before v26.12.1 it was the partial output of a failed `ASN1_TIME_print()`.\n\nRelated: #63265, which also covered the unpropagated `ASN1_TIME_print()` failure.","author":{"url":"https://github.com/ndossche","@type":"Person","name":"ndossche"},"datePublished":"2026-11-05T23:03:31Z","url":"https://github.com/nodejs/node/issues/67285"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:04b47c5d-4b8e-e41c-67ae-a319ea8dc3ec |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9F0:1FA287:4423EA:5BE8B7:6AFBECFC |
| html-safe-nonce | d2137bbe967563f76804d5c39d2292fe0c4e3f30519ce3c28558b7db39f8543a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUYwOjFGQTI4Nzo0NDIzRUE6NUJFOEI3OjZBRkJFQ0ZDIiwidmlzaXRvcl9pZCI6Ijg2MDgyNTExODUxNzc1MTAzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8a3605d11c35076f8c061e5f7abf96b075f18a115c081afeff3a765086e328b8 |
| hovercard-subject-tag | issue:6233241229 |
| 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/67285/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2b8d8e22c41d8abd7de66aa9684b75255c02879afc80a96f49b9dc3df2c74262/nodejs/node/issues/67285 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2b8d8e22c41d8abd7de66aa9684b75255c02879afc80a96f49b9dc3df2c74262/nodejs/node/issues/67285 |
| og:image:alt | Version v26.13.0 (also v26.12.0 and main) Platform Linux ARCH 7.2.14-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 30 Oct 2026 14:32:40 +0000 x86_64 GNU/Linux Subsystem crypto What steps will reproduce the b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ndossche |
| hostname | github.com |
| expected-hostname | github.com |
| None | 744d4381b1c4dbd6d8736c7d7e5bbe7dc11217584e457a3555020c631764e8ec |
| 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 | df859c48a4c8b4c0009c19bb4e82101aacb4b998 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width