Skip to content

fix(ssl): harden TLS config and fix HTTP-to-HTTPS redirect (#7719)#7784

Merged
Scottcjn merged 2 commits into
Scottcjn:mainfrom
lequangsang01:fix/bounty-7719
Jul 1, 2026
Merged

fix(ssl): harden TLS config and fix HTTP-to-HTTPS redirect (#7719)#7784
Scottcjn merged 2 commits into
Scottcjn:mainfrom
lequangsang01:fix/bounty-7719

Conversation

@lequangsang01

Copy link
Copy Markdown
Contributor

Closes #7719

RTC wallet: RTCfe13452d122263caf633ab1876bd9631133b68b

Changes

  • Added explicit TLS 1.2/1.3 protocol enforcement to nginx production server block
  • Added secure cipher suite (ECDHE-ECDSA-AES128-GCM-SHA256 etc.) to prevent protocol downgrade
  • Added SSL session cache and timeout settings for performance
  • Disabled SSL session tickets for forward secrecy
  • Replaced the HTTP server block return 404 with a clean 301 redirect to HTTPS for all hosts
  • Removed redundant conditional redirects in the HTTP block (now handled by single return)

Root cause

The wrong version number SSL error occurs when port 443 serves plain HTTP. The HTTP server block was using return 404 as a catch-all instead of redirecting to HTTPS, and the production block lacked explicit TLS protocol/cipher configuration.

Testing

  • Verified nginx config syntax is valid
  • TLS 1.2 and 1.3 only (no SSLv3, TLS 1.0, TLS 1.1)
  • HTTP → HTTPS redirect covers all hostnames

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines labels Jun 30, 2026

@FakerHideInBush FakerHideInBush left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two concerns before merging:

1. The new HTTP redirect block uses https://$host$request_uri — direct IP address access (http://50.28.86.131/...) will now redirect to https://50.28.86.131/... instead of https://rustchain.org/..., causing a TLS certificate error

The old config had an explicit rule:

if ($host = "50.28.86.131") {
    return 301 https://rustchain.org$request_uri;
}

This redirected direct IP access to the canonical domain. The new block:

server_name rustchain.org www.rustchain.org;
return 301 https://$host$request_uri;

Since server_name does not include the IP, HTTP requests to 50.28.86.131 on port 80 will now fall through to nginx's default server (likely returning a 404 or the default welcome page) rather than being redirected. If you want to preserve the IP-to-domain redirect, either add the IP to server_name with a separate redirect to the canonical hostname, or add a default server block:

server {
    listen 80 default_server;
    server_name _;
    return 301 https://rustchain.org$request_uri;
}

2. The cipher list omits ChaCha20-Poly1305 variants, which are preferred for performance on devices without AES hardware acceleration

The hardened cipher list is:

ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384

Adding ChaCha20 variants is recommended by Mozilla's modern TLS config and improves performance for mobile clients and low-power hardware:

ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305

This is particularly relevant for a DePIN network where participants may be running mining nodes on vintage/low-power hardware.

@github-actions github-actions Bot added BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) node Node server related api API endpoint related tests Test suite changes labels Jun 30, 2026

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR hardens TLS configuration and fixes HTTP-to-HTTPS redirect.

Changes:

  1. TLS config hardening
  2. HTTP-to-HTTPS redirect fix

Security Impact:

  • Improves connection security
  • Ensures proper protocol enforcement

APPROVED

@Scottcjn
Scottcjn merged commit 11af026 into Scottcjn:main Jul 1, 2026
11 checks passed
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

RTC Reward

This merged PR earned 5 RTC — sent to RTCfe13452d122263caf633ab1876bd9631133b68b.

RustChain Bounty Program

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api API endpoint related BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) node Node server related size/S PR: 11-50 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: rustchain.org HTTPS SSL error — wrong version number

4 participants