Repository navigation
Verify the server certificate by default, with ways to trust a private one - #5
Merged
Merged
Conversation
Add node:test tests against a small in-process Electrum server over TCP and TLS (with a committed, test-only certificate), covering requests, errors, concurrency, batches, notifications and close. Run them in CI on Node 18, 20 and 22. Point the repository, bugs and homepage fields at this fork, require Node 18 or later, and publish only index.js and lib.
…e one TlsSocketWrapper hard-coded rejectUnauthorized: false, so any certificate was accepted and a network attacker could impersonate the server. The options argument that the constructor already takes was not used for TLS. Verify by default, and read TLS options from options.tls: ca, servername and other tls.connect() options, rejectUnauthorized: false to skip verification as before, and fingerprint256 to accept only the certificate with that SHA-256 fingerprint (suited to self-signed servers). This is a breaking change for servers with self-signed certificates, so the version is now 2.0.0; the README says how to upgrade.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on the test harness in #1 (merge that first). Breaking: version 2.0.0.
TlsSocketWrapperhard-codedrejectUnauthorized: false, so any certificate was accepted and a network attacker could impersonate the server. Theoptionsargument the constructor already takes was not used for TLS.Verify by default, and read TLS options from
options.tls:ca,servernameand othertls.connect()options.rejectUnauthorized: falseto skip verification, as 1.x did.fingerprint256to accept only the certificate with that SHA-256 fingerprint (colons and case do not matter). It replaces chain and host name checks, so it suits self-signed servers.Tests: self-signed rejected by default; accepted with
ca, with verification off, and with the right fingerprint; rejected with a wrong fingerprint (even with verification off) and for a wrong host name. The README documents the options and how to upgrade from 1.x.