Skip to content

fix(plugin-trino): turn on TLS for port 443, refuse plaintext credentials, fix mutual TLS and URL import TLS - #3168

Merged
datlechin merged 6 commits into
TableProApp:mainfrom
J2TeamNNL:codex/fix-trino-tls-warning
Sep 28, 2026
Merged

datlechin merged 6 commits into
TableProApp:mainfrom
J2TeamNNL:codex/fix-trino-tls-warning

Conversation

@J2TeamNNL

@J2TeamNNL J2TeamNNL commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3166.

This PR started as a Network-tab warning for Trino on port 443 (thanks @J2TeamNNL for the first pass). Review found the warning left the cause in place and pointed at a mode the form refused to save, so the branch now carries the fix itself, plus the TLS defects the investigation turned up next to it.

Root cause

TablePro picked the SSL mode from the database type alone. A Trino connection typed as host:443 kept SSL Disabled, and the driver sent http://host:443/v1/statement to an HTTPS listener, which nginx answers with 400 The plain HTTP request was sent to HTTPS port. Every Trino client does the opposite: the JDBC driver (TrinoUri.isSecureConnection: scheme trino and port 443), the CLI (port == 443 ? "https" : "http") and trino-python-client all switch to HTTPS on 443 and verify the certificate against the platform trust store. That is why the reporter's DBeaver connection works.

The ways out were broken too. Verify Identity could not be saved without a CA file, although Trino's transport already checks the system trust store when none is set. The modes that could be saved, Preferred and Required, skip certificate checks for Trino. And every failure reached the user as raw nginx HTML or "Query was cancelled".

What changed

Ports that mean TLS (commit 1)

  • Plugin metadata, not type checks. Curated capabilities carried over when a plugin registers: tlsImpliedPorts (Trino [443]; ClickHouse [8443, 443], matching clickhouse-connect, first entry is the driver's TLS port) and verifiesServerWithSystemTrust (Trino, ClickHouse). SQL Server's hidden CA field moved to the same metadata (supportsPerConnectionCertificatePaths).
  • Connection form. SSLPaneViewModel records where its mode came from (type default, implied by the port, chosen). Typing a TLS port while the mode is still the default selects Verify Identity, typing another port restores the default, and a mode the user picked is never changed. Opening a stored connection never rewrites it. Under Port, a note says the port turned TLS on; a connection that is Disabled on a TLS port gets a caution and a Use Verify Identity button.
  • Validation. Verify Identity saves without a CA file on drivers that check the system trust store. Verify CA still requires one, because it checks no hostname.
  • Trino transport. Certificate challenges are answered by each request's own delegate, so a refused certificate is reported as a certificate failure rather than a cancel. Plain HTTP refused by a TLS port, untrusted certificates and hostname mismatches map to SSLHandshakeError. PEM CA files work. HTML error pages read as their title.
  • ClickHouse. Verify Identity honours a chosen CA file, which it ignored.

Collateral fixes (commit 2)

  • Trino credentials never go over plain HTTP. With SSL Disabled, a password or JWT is refused before the first request (TrinoStatementClient is the single check; the plugin maps it to the user's words). A coordinator on plain HTTP ignores the token and trusts the user name alone, so sending it bought nothing and leaked it.
  • Trino redirects are refused. Trino never redirects, so a 3xx comes from a proxy. URLSession turned a 301/302 on POST /v1/statement into a GET and followed it, to another host or to plain HTTP. The error now names the target and, for an https:// redirect on the same host, the port to use.
  • Trino and etcd mutual TLS. New TableProTLSClientIdentity target: SecItemImport with no keychain, CryptoKit for EC keys, SecIdentityCreate, URLCredential. It reads PKCS#1, PKCS#8 and SEC1 keys in PEM or DER, refuses encrypted keys with a message, and never writes to a keychain. The old paths crashed on an RSA PRIVATE KEY file, rejected other key forms, and etcd's added each key to the login keychain for the length of the call. A server that asks for a certificate and gets none, or rejects the one sent, is told apart from a connection dropped after the server began answering (URLSessionTaskMetrics.responseStartDate).
  • Verify CA without a CA file is refused on Trino, ClickHouse and etcd instead of accepting any certificate from the system roots for any host. An unreadable CA file fails the connect with the path named instead of widening to the system roots. ClickHouse and etcd read the CA once, when the connection starts, and etcd now reads PEM as well as DER.
  • URL import. jdbc: in front of a known scheme is dropped, and JDBC user=/password= fill the credentials when the URL carries none. Trino's SSL=true and SSLVerification=FULL|CA|NONE, ClickHouse JDBC's sslmode=strict|none, and VERIFY_FULL-style spellings are read. A URL that turns TLS on and names no port opens on the driver's TLS port, and a written port is kept.
  • Deep links use the same rules as Import from URL. A link opened from a browser or open used to ignore the driver's default SSL mode, so a PostgreSQL link ran without Preferred's TLS. Both paths now resolve through one SSLModeResolution.
  • Copied URLs keep their SSL mode. Disabled was dropped, and a TLS-port connection's mode was left for the port to imply, which other clients do not read.
  • Error text. The shared SSLHandshakeError recovery strings named an "SSL tab" that no longer exists. They now name the Network tab, and the hostname-mismatch advice no longer suggests Verify CA, which only moves the problem.

No PluginKit ABI change: only existing public symbols are used and the SSLHandshakeError edits are string bodies (scripts/check-pluginkit-abi.sh: unchanged). The Trino and etcd halves need plugin-trino and plugin-etcd releases to reach users; the form, URL import and ClickHouse changes ship with the app.

Split out into their own PRs: the health monitor retrying TLS configuration failures forever (#3170), and Verify CA without a CA file on Kafka, Oracle and Teradata (#3171).

Before / After

ClickHouse, port typed as 8443 on a new connection:

Before After
Before: port 8443 with no note, SSL still Disabled After: note under Port saying port 8443 uses TLS

Verification

  • verify.sh build PASS, verify.sh plugins (AllPlugins, all 40 plugins) PASS.
  • Unit tests: 370/370 across the 16 suites that own the changed code, including ConnectionURLParserTests (the full existing parser suite), ConnectionURLParserJDBCTests, ConnectionURLParserTLSPortTests, ImportedSSLModeResolutionTests (form and deep link agree on mode and port for the same URL), ConnectionURLFormatterTests, ClickHouseTLSConfigurationTests, EtcdServerTrustTests, TrinoSSLMappingTests, SSLPaneViewModelTests, ConnectionFormPortTLSTests and DatabaseTypeTests.
  • TableProTrinoCore and TableProTLSClientIdentity packages: 90 XCTest and 60 Swift Testing cases pass. TrinoMutualTLSTests runs a real NWListener TLS server that requires a client certificate, over TLS 1.2 and 1.3: the certificate is presented, a certificate from another CA is reported as rejected, a missing one as required, and a connection dropped mid-response as a transport failure. That last test fails with the responseStartDate check removed.
  • UI test ConnectionFormTLSPortUITests: 4/4. Typing 8443 shows the note and selects Verify Identity, typing 8123 reverts it, and Disabled on 8443 offers Use Verify Identity.
  • swiftlint lint --strict on every changed file: no violations on changed lines. docs/ style, source and link checks clean.

@datlechin datlechin changed the title fix(trino): warn when port 443 has TLS disabled fix(connection-form): turn on TLS for Trino on port 443 and ClickHouse on 443 and 8443 Sep 28, 2026
@datlechin datlechin changed the title fix(connection-form): turn on TLS for Trino on port 443 and ClickHouse on 443 and 8443 fix(plugin-trino): turn on TLS for port 443, refuse plaintext credentials, fix mutual TLS and URL import TLS Sep 28, 2026
@datlechin
datlechin merged commit bc91886 into TableProApp:main Sep 28, 2026
13 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.

Failed to connect to DB on 443 port

2 participants