René's URL Explorer Experiment


Title: crypto: clear OpenSSL error queue after calling X509_verify() by takuro-sato · Pull Request #45377 · nodejs/node · GitHub

Open Graph Title: crypto: clear OpenSSL error queue after calling X509_verify() by takuro-sato · Pull Request #45377 · nodejs/node

X Title: crypto: clear OpenSSL error queue after calling X509_verify() by takuro-sato · Pull Request #45377 · nodejs/node

Description: Prior to this commit, functions accessing the OpenSSL error queue did not work properly after x509.verify() returned false. Example code to reproduce the bug const crypto = require('crypto'); const cert0 = new crypto.X509Certificate( '-----BEGIN CERTIFICATE-----\n' + 'MIICeTCCAWGgAwIBAgIBADANBgkqhkiG9w0BAQsFADAAMB4XDTIyMTEwNzExMzU0\n' + 'NloXDTIyMTEwNzExMzU0NlowADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n' + 'ggEBAKXDiNM5kCg3m7mBmLGhTWDLo3rEDf7nfI77V2rS9jXg0wV1LvnxQcYFeUud\n' + 'zfvZpSc07TdmSDWJhE04/9G2fk86RwnMYj9KBLCgqzjk/wnrlcB8BuFPC5ZUKm+e\n' + 'OmpfwzxRsqU0dlp/C6BmZV8cuvOKbxcq7MnACmS3lOvDUIdXjkEI1LEkzQudQNQi\n' + 'S2PDPRUFm5KDkLmky2MACUkUA1eGMI8GLV60fzrsMnD6/lIGgDgRjcMdtv7D0F0K\n' + 'D/AbCfXv4Z6SCKgp+0nLC5PpacNWu0yk1y4ihm9BHCRrxGcMzX5ce9pUfXVt6nUA\n' + 'gwzlTcMno28yb16dBd9+XdQu/p8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAVaRJ\n' + 'CSOGycfz+bOGvSkLIOGWjtRoeaX/hMwCB/b0BuAVmcyWJuPsPcghwDnNUJAlxDnB\n' + 'R7F6+J9P2kv7V+B4nlB/w0YHbidlSGeyd7AENsHqwYzOaoGCcr0B8pQrocj5Dm3g\n' + 'JmPGMmMSa+MJfPD5j1///plvbLzBdG8nm9nG1yzOho+4lJf0VUwDnVEcRJp1w7kF\n' + 'Ys19JJo78BEnUHJMOv1vE1KINY1k6wB69BJwZoW6tDjwHcHAtWzOA6324r+2tmnK\n' + 'HCKAw78IZsDjLtC13LtrqFgWXzOh6WkLGmS7W01Coi3+uZcmWwJv/8m+2VlOXgrg\n' + 'iQYf67llQlRAay0wnA==\n' + '-----END CERTIFICATE-----\n' ); const cert1 = new crypto.X509Certificate( '-----BEGIN CERTIFICATE-----\n' + 'MIICeTCCAWGgAwIBAgIBADANBgkqhkiG9w0BAQsFADAAMB4XDTIyMTEwNzExMzU0\n' + 'N1oXDTIyMTEwNzExMzU0N1owADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n' + 'ggEBAOc1bvNUvDCUxLhgNc9oQ8WwXsVSGHWaulf93eA1m9oB3kzvoCbEURN1k/dv\n' + 'QoeLhovosZqnyz4W/2o+RHwCy/PNi3FGGaFGcpMTdwEGLn8TlGcUKv32h1Her+og\n' + 'XnwGqZizD8xBbqfi5WRcX3JS02EKC8BVlDQiru2eToR+T6ZiOIGRZDNYYHUGvoSz\n' + '0nFiLzFLEwuMhEJhGmXcy0JyWx4BnYwEYYnwdKSAPakYFzvePMvpYyX2Xg4eD65j\n' + 'kBRtKSYxDK39rXR6BfH7UpVjsY6H3TlVXYQdkxBPfzZlCPJBMG6TJRl2IzYJU1H4\n' + 'JK84mEhDGnE9fxxvxykYX5a7YYMCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAAPcQ\n' + 'cA6MFAGvbrACFYKHx7rMZ/HxjEps47Dq8zapqPWaTZVCSRI3si8lH99UW0DCRlRJ\n' + 'VQnW2l7Ag7edp2RLQlCoH8gzEkCXvG3CNVE+U82WnlsUA+FTTV+X4W9Va3nNe2ZU\n' + 'B8SO4V0374osYlM5UaUz9VWU3ulBupufQ9wdJTEVPcfEekDXVGeJIFeiyafhIYrB\n' + 'H6OA1xhS0Yf2NtEIup2vexJ3wOxXh1ZyPR190Jr2b9ePylcUU2DWSCMvnzFdCPLt\n' + 'aHR8RktrScK8BVXMag2Fvvgoco0XCIoWl/kPN3I0SnvIcTHa/uWA49ijMqwM1yDc\n' + 'Timu77Xm/VYec/v1qg==\n' + '-----END CERTIFICATE-----\n' ) const cert2 = new crypto.X509Certificate( '-----BEGIN CERTIFICATE-----\n' + 'MIICeTCCAWGgAwIBAgIBADANBgkqhkiG9w0BAQsFADAAMB4XDTIyMTEwNzExMzU0\n' + 'N1oXDTIyMTEwNzExMzU0N1owADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n' + 'ggEBAJwgfV4eP/rsHYVtuCBvahP7tWJ/Djs9V11NHuVB11zUng2NiwfT3qvRfR/G\n' + 'kc+fEUB/8K9kV4kGiFwB+xOKZ/0vpiRVKINPhrDJYdehahlT5iwF3dkTqNARp9MK\n' + 'Dk1z3iAa0aQXNXCwIUNhs+8GZmXHZn8AOjAcBz03alBwUaYINMQVfjERT+BOCr7E\n' + 'wK793iY8knF0ZT07GKIzqRFJhueBA+VKfoXluSSa7SoAO3UwYt72k1UIdUjA5C73\n' + 'I8ZnlmIAVldjpO4AZdhwcVrHth54G3SAtt/vjk3052iJXpICduPWCUCF+pZDkRSO\n' + 'DkSNfzaxr40I2raP0hvveUiArBUCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAjkdh\n' + 'B0fyPt2Gyt5KRoCqsy8dS3iEhT98YzULeBk+mtcJXsbH8aEBXQzqzSnYfP3LeDxK\n' + 'xP87pcP+V9sruQixHGNYQqRar8jpBuAhQAX8aqgWe4rc++3RbotafYJ7ILRj3J6K\n' + '0JXB3YXxjk7vp0aO/eaodKFM3g5EnKtXHH37yDZMQ665RPglh+MoJOw4BVutLPh4\n' + 'MpmTY1yxl/HbIvqv8uQw55ftjXSaRB/pCCh4IjcQ3LS9FXE4pdESwgKScy8JsiDt\n' + 'z/BtAH3hG/AbVon2RWBF4d5exFl4aJj3CSNKvMlu7q/CSbDWxdCafO433QRsI6SV\n' + 'fW0jkmnFsvaUpOAF0w==\n' + '-----END CERTIFICATE-----\n' ); const privateKeyPem = '-----BEGIN PRIVATE KEY-----\n' + 'MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgo5BAQydImlcOf1LS\n' + '7FrRfoBgHHUqevagq/1nmv3thMChRANCAAQ/oNhs1q1GJ4OOats5kaARTOPBZgzb\n' + 'MpVnfwmmLDYGOJotCe0sVAUMYBCQ4DHko9DdOH6HWPSiGAzohs4nwDZz\n' + '-----END PRIVATE KEY-----'; const privateKey = crypto.createPrivateKey({key: privateKeyPem}) console.log(privateKey.asymmetricKeyDetails) // { namedCurve: 'prime256v1' } crypto.createPrivateKey({key: privateKeyPem}) console.log(cert1.verify(cert2.publicKey)) // true crypto.createPrivateKey({key: privateKeyPem}) console.log(cert0.verify(cert2.publicKey)) // false crypto.createPrivateKey({key: privateKeyPem}) // It throws and error is about RSA key even though `key` is prime256v1 output: { namedCurve: 'prime256v1' } true false node:internal/crypto/keys:620 handle.init(kKeyTypePrivate, data, format, type, passphrase); ^ Error: error:0200008A:rsa routines::invalid padding at Object.createPrivateKey (node:internal/crypto/keys:620:12) at Object. (/home/takuro/Projects/dev_node/bug.js:76:8) at Module._compile (node:internal/modules/cjs/loader:1159:14) at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) at Module.load (node:internal/modules/cjs/loader:1037:32) at Module._load (node:internal/modules/cjs/loader:878:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12) at node:internal/main/run_main_module:23:47 { opensslErrorStack: [ 'error:06880006:asn1 encoding routines::EVP lib', 'error:1C880004:Provider routines::RSA lib', 'error:02000072:rsa routines::padding check failed' ], library: 'rsa routines', reason: 'invalid padding', code: 'ERR_OSSL_RSA_INVALID_PADDING' } Node.js v19.0.1 Note I got an error when I ran make -j4 test locally, but I believe it's not related to this PR because I got the same one with the latest main and v19.0.1. make -s jstest ninja: Entering directory `out/Release' ninja: no work to do. === release test-tls-dhe === Path: parallel/test-tls-dhe Command: out/Release/node --no-warnings /home/takuro/Projects/node/test/parallel/test-tls-dhe.js --- TIMEOUT --- [05:04|% 100|+ 3769|- 1]: Done make[1]: *** [Makefile:307: jstest] Error 1 make: *** [Makefile:333: test] Error 2

Open Graph Description: Prior to this commit, functions accessing the OpenSSL error queue did not work properly after x509.verify() returned false. Example code to reproduce the bug const crypto = require('crypto'...

X Description: Prior to this commit, functions accessing the OpenSSL error queue did not work properly after x509.verify() returned false. Example code to reproduce the bug const crypto = require('crypto...

Opengraph URL: https://github.com/nodejs/node/pull/45377

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:22086636-0e96-e578-f2fb-b74529130b6e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE7C4:373A8C:9200A3:BA2839:6B0364C8
html-safe-noncedbf20f3a3e3f2c4de0272569b05987da98e47faec8594ce245d585aed3640b95
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0M0OjM3M0E4Qzo5MjAwQTM6QkEyODM5OjZCMDM2NEM4IiwidmlzaXRvcl9pZCI6IjQzNzg5NzgzNDQxNjM4Mjg5MzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac734d78e1024739e88d89e7c1c08a3910b6027b23c2ff8a840fb61cfde6eb71cf
hovercard-subject-tagpull_request:1114651311
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/nodejs/node/pull/45377/files
twitter:imagehttps://avatars.githubusercontent.com/u/79583855?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/79583855?s=400&v=4
og:image:altPrior to this commit, functions accessing the OpenSSL error queue did not work properly after x509.verify() returned false. Example code to reproduce the bug const crypto = require('crypto'...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/pull/45377/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F45377%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F45377%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/pull/45377/files
Reloadhttps://github.com/nodejs/node/pull/45377/files
Reloadhttps://github.com/nodejs/node/pull/45377/files
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues639 (639)https://github.com/nodejs/node/issues
Pull requests667 (667)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
nodejs-github-bothttps://github.com/nodejs-github-bot
nodejs:mainhttps://github.com/nodejs/node/tree/main
takuro-sato:clear-error-queuehttps://github.com/takuro-sato/node/tree/clear-error-queue
Conversation 13 https://github.com/nodejs/node/pull/45377
Commits 4 https://github.com/nodejs/node/pull/45377/commits
Checks 0 https://github.com/nodejs/node/pull/45377/checks
Files changed https://github.com/nodejs/node/pull/45377/files
Please reload this pagehttps://github.com/nodejs/node/pull/45377/files
crypto: clear OpenSSL error queue after calling X509_verify() https://github.com/nodejs/node/pull/45377/files#top
Show all changes 4 commits https://github.com/nodejs/node/pull/45377/files
b65799c crypto: clear OpenSSL error queue after calling X509_verify() takuro-sato Nov 8, 2022 https://github.com/nodejs/node/pull/45377/commits/b65799c9e4eb1e56ca8ff8279acdc2c70a0ab496
2775ffc use ClearErrorOnReturn instead of ERR_clear_error() takuro-sato Nov 8, 2022 https://github.com/nodejs/node/pull/45377/commits/2775ffc4f338fc8c567d8391402c126d8a20a24e
5003cc9 improve comment takuro-sato Nov 8, 2022 https://github.com/nodejs/node/pull/45377/commits/5003cc93790183cb43c97173db0e783e7a0633b2
f26f710 improve comment takuro-sato Nov 8, 2022 https://github.com/nodejs/node/pull/45377/commits/f26f710858afbed259b9b6a5cfeedea1529c481f
Clear filters https://github.com/nodejs/node/pull/45377/files
Please reload this pagehttps://github.com/nodejs/node/pull/45377/files
Please reload this pagehttps://github.com/nodejs/node/pull/45377/files
crypto_x509.cc https://github.com/nodejs/node/pull/45377/files#diff-a6498994a51e8c4fba2f74d8e22a2c95bb784cef168387bc4b800d63a605aedd
test-crypto-x509.js https://github.com/nodejs/node/pull/45377/files#diff-08202f949361102cb4056e1f852d8815dac96713aee34a1759f42a05f6ee9895
src/crypto/crypto_x509.cchttps://github.com/nodejs/node/pull/45377/files#diff-a6498994a51e8c4fba2f74d8e22a2c95bb784cef168387bc4b800d63a605aedd
View file https://github.com/takuro-sato/node/blob/f26f710858afbed259b9b6a5cfeedea1529c481f/src/crypto/crypto_x509.cc
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/45377/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/45377/files#diff-a6498994a51e8c4fba2f74d8e22a2c95bb784cef168387bc4b800d63a605aedd
https://github.com/nodejs/node/pull/45377/files#diff-a6498994a51e8c4fba2f74d8e22a2c95bb784cef168387bc4b800d63a605aedd
test/parallel/test-crypto-x509.jshttps://github.com/nodejs/node/pull/45377/files#diff-08202f949361102cb4056e1f852d8815dac96713aee34a1759f42a05f6ee9895
View file https://github.com/takuro-sato/node/blob/f26f710858afbed259b9b6a5cfeedea1529c481f/test/parallel/test-crypto-x509.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/45377/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/45377/files#diff-08202f949361102cb4056e1f852d8815dac96713aee34a1759f42a05f6ee9895
https://github.com/nodejs/node/pull/45377/files#diff-08202f949361102cb4056e1f852d8815dac96713aee34a1759f42a05f6ee9895
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.