From 5d6ecec284684f76c297023eb6eeeea3e1420b06 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 13 Jul 2026 12:50:31 -0500 Subject: [PATCH] fix: disable SSL for .onion domains in SOCKSSocket.connectTo Onion services are already end-to-end encrypted by the Tor protocol, so attempting a TLS handshake on top of a .onion connection is unnecessary and fails against services that do not present a certificate. Skip the SSL upgrade automatically when the target domain ends with .onion. --- lib/socks_socket.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/socks_socket.dart b/lib/socks_socket.dart index d5ca64f..82f2ffb 100644 --- a/lib/socks_socket.dart +++ b/lib/socks_socket.dart @@ -93,7 +93,7 @@ class SOCKSSocket { StreamSubscription>? get subscription => _subscription; /// Is SSL enabled? - final bool sslEnabled; + bool sslEnabled; /// Private constructor. SOCKSSocket._(this.proxyHost, this.proxyPort, this.sslEnabled); @@ -216,6 +216,12 @@ class SOCKSSocket { /// Returns: /// A Future that resolves to void. Future connectTo(String domain, int port) async { + // Onion services provide their own end-to-end encryption, so disable the + // TLS upgrade when connecting to a .onion domain. + if (domain.endsWith('.onion')) { + sslEnabled = false; + } + // Connect command. var request = [ 0x05, // SOCKS version.