Skip to content

Verify the server certificate by default, with ways to trust a private one - #5

Merged
2rdzy merged 2 commits into
masterfrom
feat/tls-verification
Oct 6, 2026
Merged

2rdzy merged 2 commits into
masterfrom
feat/tls-verification

Conversation

@2rdzy

@2rdzy 2rdzy commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Builds on the test harness in #1 (merge that first). Breaking: version 2.0.0.

TlsSocketWrapper hard-coded rejectUnauthorized: false, so any certificate was accepted and a network attacker could impersonate the server. The options argument 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 1.x did.
  • fingerprint256 to 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.

2rdzy added 2 commits October 5, 2026 22:14
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.
@2rdzy
2rdzy merged commit 4d08c8d into master Oct 6, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant