Skip to content

fix(tls): trust the OS certificate store in addition to the bundled roots - #628

Merged
hogan-yuan merged 5 commits into
mainfrom
fix/tls-trust-os-root-store
Nov 19, 2026
Merged

hogan-yuan merged 5 commits into
mainfrom
fix/tls-trust-os-root-store

Conversation

@hogan-yuan

@hogan-yuan hogan-yuan commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Behind a corporate TLS-inspecting proxy (Zscaler and the like) every HTTPS call failed with invalid peer certificate: UnknownIssuer, while other clients on the same machine reached the same endpoint fine.

Refs longbridge/developers#1153. The CLI needs the matching change: longbridge/longbridge-terminal#351.

Cause

The proxy's root CA is installed in the OS trust store. The SDK asked reqwest and tokio-tungstenite for the bundled webpki roots only, so the OS store was never consulted and no CA-bundle environment variable could add to it:

reqwest           = { features = ["rustls-tls", ...] }   # = rustls-tls-webpki-roots
tokio-tungstenite = { features = ["rustls-tls-webpki-roots"] }

Fix

Enable the native-roots feature alongside the webpki one, in the HTTP client, the geo lookup and the WebSocket client. Each root set defaults to enabled when its feature is on, so the trust change itself needs no code.

This is a security-posture decision, not just a bug fix

Worth stating explicitly rather than leaving a reviewer to infer it. Before this change the SDK trusted only the roots compiled into the binary, which made it immune to a CA injected into the local trust store. After it, a root certificate installed on the machine can intercept trading traffic — which is exactly what the reporter wants, because that is how their employer's proxy works.

For a trading SDK that trade-off deserves a conscious yes. The argument for it: the machine's trust store is already the trust anchor for every other tool on that host, an attacker who can install a root CA has administrative control anyway, and refusing to honour it only pushes users toward disabling verification entirely. But it is a real widening, and it should be approved as one.

Why this is a superset, not a swap

I read both libraries at the versions the lockfile actually resolves — tokio-tungstenite 0.27, not the latest — rather than assuming.

reqwest (async_impl/client.rs) adds both sets to the same root_cert_store:

if config.tls_built_in_certs_webpki { /* extend with webpki roots */ }
if config.tls_built_in_certs_native { /* extend with rustls_native_certs */ }

tokio-tungstenite 0.27 (src/tls.rs) does the same, and explicitly treats an empty native store as non-fatal when webpki roots are also present:

// Not finding any native root CA certificates is not fatal if the
// "rustls-tls-webpki-roots" feature is enabled.
#[cfg(not(feature = "rustls-tls-webpki-roots"))]
if certs.is_empty() { return Err(...) }

So a machine with an empty or unreadable OS store behaves exactly as it did before.

Cargo.lock says nothing here: /Cargo.lock is in this repo's .gitignore and is not tracked. An earlier version of this description claimed it was "unchanged", which reads like verified dependency stability and is not. (longbridge-terminal does track its lockfile, so the same statement on longbridge/longbridge-terminal#351 is real.)

Second commit: don't pay for the OS store on every connection

Reviewing the first commit turned up a regression it introduced. wsclient calls connect_async with no connector, so tokio-tungstenite builds a fresh rustls::ClientConfig per connection — and rustls-native-certs does not cache. Measured on macOS:

run 0: 135ms  certs=163      (five consecutive calls, no caching)
run 1:  89ms  certs=163
run 4:  95ms  certs=163

The HTTP side is fine: SHARED_HTTP_CLIENT is a LazyLock, so it reads the store once per process. The WebSocket side held two connections and rebuilt them on every reconnect, so a flapping network would have paid ~90ms each time.

The second commit builds the connector once in a LazyLock and passes it to connect_async_tls_with_config, assembling the root set exactly as tokio-tungstenite 0.27 assembles its own. Verified by counting initialisations across three contexts: the native store is read once, not three times.

That makes rustls a direct dependency, which surfaced a second latent problem: the workspace resolves rustls with the ring provider only via reqwest, and ClientConfig::builder() panics at runtime without a provider — so longbridge-wscli was not buildable as a standalone crate. The provider is now named explicitly. aws-lc-rs is absent from the lockfile, so there is no ambiguity, and the resolved feature set for the main build is unchanged.

Verification

On macOS, three clients against openapi.longbridge.com:

native-only  -> Ok(404)
webpki-only  -> Ok(404)
shared(both) -> Ok(404)

(404 is the expected answer for /.) Neither root set is load-bearing on its own, and the shared client works with both. The WebSocket path was exercised against the test gateway: the connection reaches the application layer, so the cached connector completes a real TLS handshake.

What this does not prove: I could not reproduce the TLS-inspection case itself — there is no such proxy here. That the fix resolves it follows from the proxy CA being in the OS store, which the reporter confirmed by reaching the same endpoint with PowerShell on the affected machine. The part I verified is that the OS store is now loaded and sufficient.

cargo clippy --all --all-features: diffed against main, zero new warnings. Tests pass.

🤖 Generated with Claude Code

hogan-yuan added a commit that referenced this pull request Nov 19, 2026
No workflow in this repo declares a `concurrency` group, so every push
to a pull request queues another full CI matrix and **the run it
replaced keeps its place in line**.

## What that looked like

Observed while iterating on #627 and #628:

```
全仓库最近 12 次运行:queued=6, completed=6
最近一次真正完成的运行:186 分钟前
最老的排队运行:187 分钟
```

Six runs queued at once; four were for commits that were no longer any
branch's HEAD. Nothing started for roughly three hours. Cancelling the
four obsolete runs by hand is what got the queue moving again:

```
44282677026  b18750b  superseded → cancelled
44266307848  b846aea  superseded → cancelled
44265659864  acc1c25  superseded → cancelled
44259650117  3e99304  superseded → cancelled
```

With nine jobs fanning out across a wide platform matrix, each obsolete
run is a lot of runner time spent on a commit nobody is waiting for.

## The change

```yaml
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true
```

`github.head_ref` is set **only** for `pull_request` events, so:

- **a pull request** groups by its branch — a new commit cancels the run
for the commit it replaced
- **a push to main** falls back to `github.run_id`, which is unique per
run, so those get a group of their own: never cancelled, and never made
to queue behind each other either

That second half matters. The naive `group: ${{ github.workflow }}-${{
github.ref }}` would put every main push in one group — either
cancelling a main run that a later commit supersedes, or serialising
them.

## Why only `ci.yml`

The other five workflows should not cancel, so they are untouched:

| workflow | trigger | why not |
|---|---|---|
| `release.yml` | push to `release` | publishes artifacts; aborting
halfway is worse than running twice |
| `docs.yml` | push to `release` | deploys docs; same |
| `check_docs.yml` | push to `main` | main only, infrequent |
| `close-slate-issues.yml` | weekly cron | nothing to supersede |
| `issue-notify.yml` | issue opened | nothing to supersede |

## Related, deliberately not bundled

- **longbridge-mcp** has no concurrency group in any of its four
workflows.
- **longbridge-terminal** has one in three of seven, but not in
`test.yml`.

Both are worth the same change, but neither has shown this backlog —
their CI is small where this one fans out — so they belong in their own
PRs rather than here.

## Honest note on how this came up

A good part of the backlog was self-inflicted: I pushed small follow-up
commits to #627 and #628 seven times while reviewing them, and in a repo
with no concurrency group each of those reset a full matrix. The fix is
worth having regardless, but the measurement above is as much a
description of my own push cadence as of the CI configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@hogan-yuan
hogan-yuan force-pushed the fix/tls-trust-os-root-store branch from 6723a8a to 24c1a57 Compare November 19, 2026 02:05
hogan-yuan added a commit to longbridge/longbridge-mcp that referenced this pull request Nov 19, 2026
…oots

Behind a corporate TLS-inspecting proxy every HTTPS call fails with
`invalid peer certificate: UnknownIssuer`, because reqwest was configured
with `rustls-tls` -- the bundled webpki roots and nothing else -- so the OS
trust store, where such a proxy installs its CA, was never consulted.

This is the same defect reported against the CLI in
longbridge/developers#1153. The SDK and the CLI are being fixed in
longbridge/openapi#628 and longbridge/longbridge-terminal#351; the MCP
server is the third entry point and had the same configuration, so a user
behind that proxy cannot run it either.

Enable `rustls-tls-native-roots` alongside `rustls-tls-webpki-roots`.
reqwest adds both sets to the same root store rather than choosing between
them, so this is a superset of what was trusted before: a machine with an
empty or unreadable OS store behaves exactly as it did.

This widens what the server trusts -- a root certificate installed on the
machine can now intercept its traffic. That is the point for the reporter's
case, and the reasoning for accepting it is set out in openapi#628.

No caching work is needed here, unlike the SDK: the OAuth proxy and the fx
tool already hold their clients in a `LazyLock`, and the only remaining
inline build is the authorization-code exchange, which runs once per
authentication.

Verified: a client built with the native roots alone reaches
openapi.longbridge.com, so the OS store is loaded and sufficient on its own.
The proxy case itself could not be reproduced here.

Note for a follow-up: this lockfile already resolved three different
webpki-roots versions (0.25.4, 0.26.11, 1.0.9) before this change. That is
pre-existing and untouched here.
…oots

Behind a corporate TLS-inspecting proxy every HTTPS call failed with
`invalid peer certificate: UnknownIssuer`, including `longbridge auth
login` at `/oauth2/register`, while other clients on the same machine
worked. The proxy's root CA is installed in the OS trust store, but the SDK
asked reqwest and tokio-tungstenite for the bundled webpki roots only, so
the OS store was never consulted and no environment variable could add to
it.

Enable the native-roots feature alongside the webpki one in the HTTP
client, the geo lookup and the WebSocket client. Both libraries add the two
sets to the same root store rather than choosing between them, and
tokio-tungstenite explicitly treats an empty native store as non-fatal when
webpki roots are also present, so this is a superset of what was trusted
before: a machine with an empty or unreadable OS store behaves exactly as
it did. No code change is needed — each root set defaults to enabled when
its feature is on.

Verified on macOS that a client built with the native roots alone reaches
openapi.longbridge.com, as does one built with the webpki roots alone, so
neither set is load-bearing by itself. The proxy case itself could not be
reproduced here; it follows from the proxy CA being in the OS store, which
the reporter confirmed by reaching the same endpoint with PowerShell.

Cargo.lock is unchanged: rustls-native-certs was already in the graph.

Refs longbridge/developers#1153
Trusting the OS certificate store made every WebSocket connection pay for
reading it. `connect_async` takes no connector, so tokio-tungstenite builds
a fresh `rustls::ClientConfig` per connection, and `rustls-native-certs`
does not cache: a measured `load_native_certs()` on macOS costs ~90ms every
call (135ms cold, 89-95ms warm, 163 certs). The SDK holds two of these
connections and rebuilds them on every reconnect, so a flapping network
would pay it over and over.

Build the connector once in a `LazyLock` and hand it to
`connect_async_tls_with_config`. The root set is assembled exactly as
tokio-tungstenite 0.27 assembles its own: native certs added first, with
loading errors logged and an empty result tolerated, then the bundled
webpki roots unioned on top. So what is trusted does not change; only how
often it is computed does.

Verified by counting initialisations across three contexts: the native
store is read once, not three times.

rustls becomes a direct dependency, so name the crypto provider explicitly
rather than relying on another crate in the graph to turn one on: `ring` is
what the workspace already resolves to via reqwest, and aws-lc-rs is absent
from the lockfile, so there is no ambiguity and the resolved feature set for
the main build is unchanged. Without a provider feature
`ClientConfig::builder()` panics at runtime, which would have made
longbridge-wscli unusable on its own.

Cargo.lock is unchanged.
Same defect as the WebSocket connector, in a path the first review missed.
`create_http_client` is called from three places, and one of them is
`refresh_token`, which runs for the lifetime of the process. Each call did a
full `reqwest::Client::builder().build()`, and now that the TLS config
trusts the OS certificate store that build reads the platform trust store
synchronously.

Measured on macOS: a fresh `build()` costs 90-145ms, so every token refresh
paid it. Behind a `LazyLock` the first call takes 160ms and the next takes
333ns -- it is a clone of an internally reference-counted handle, which also
means refreshes now share a connection pool instead of discarding one each
time.

A failed build is deliberately not cached as a failure: the next call
rebuilds so the caller still receives the real `reqwest::Error` rather than
a sticky one from startup.

No test asserts the timing; a wall-clock assertion would be flaky in CI, and
`LazyLock` already guarantees the build happens once.
Making wsclient a direct dependent of webpki-roots to build the shared
connector added `webpki-roots = "0.26"`, following what tokio-tungstenite
uses. That is not what the rest of the stack uses: hyper-rustls, and so
reqwest, resolve webpki-roots 1.0. The result was two copies of the crate
in every binary, with the WebSocket path trusting a different, older CA
snapshot than the HTTP path.

Move the direct dependency to `webpki-roots = "1"`, and drop
`rustls-tls-webpki-roots` from tokio-tungstenite, which is what pulled the
0.26 copy. Both of its root features exist only to gate its own root
loading, which this crate never reaches now that every connection passes an
explicit connector; one of them still has to be on for `Connector::Rustls`
and `connect_async_tls_with_config` to exist, so `rustls-tls-native-roots`
stays. Its dependency, rustls-native-certs, is one we already take directly.

Verified: the lockfile now resolves a single webpki-roots (1.0.6), the
connector builds with 136 roots, and a real wss:// handshake against the
test gateway still completes.

Also correcting something stated in the first commit of this branch:
"Cargo.lock is unchanged" says nothing in this repo, because `/Cargo.lock`
is in .gitignore and is not tracked at all. It reads like a verified claim
about dependency stability and is not one. (longbridge-terminal does track
its lockfile, so the equivalent statement there is real.)
The entry described the change as strictly additive -- two root sets
unioned, nothing previously working breaks -- which is true and only half
the story. Trusting the platform store also means a CA installed on the
machine can now intercept SDK traffic, where before it could not.

That belongs in the changelog, not only in the pull request: the people who
need to know are the ones reading release notes, not reviewing the diff.
@hogan-yuan
hogan-yuan force-pushed the fix/tls-trust-os-root-store branch from 24c1a57 to 2af0a19 Compare November 19, 2026 07:30
hogan-yuan added a commit to longbridge/longbridge-terminal that referenced this pull request Nov 19, 2026
…oots (#351)

`longbridge auth login` fails behind a corporate TLS-inspecting proxy:

```
Authentication failed: Client registration request failed: error sending request
for url (https://openapi.longbridge.com/oauth2/register): client error (Connect):
invalid peer certificate: UnknownIssuer
```

PowerShell reaches the same endpoint fine on the same machine and gets a
normal API error back, so the proxy's root CA is trusted by Windows —
just not by us.

Refs longbridge/developers#1153. Pairs with longbridge/openapi#628,
which makes the same change in the SDK.

## Cause

`reqwest` was configured with `rustls-tls`, which is
`rustls-tls-webpki-roots`: the bundled root bundle and nothing else. The
OS trust store, where the proxy CA is installed, was never consulted,
and no CA-bundle environment variable could add to it.

## Fix

Enable `rustls-tls-native-roots` alongside `rustls-tls-webpki-roots` — a
one-line change to `Cargo.toml`. reqwest adds both sets to the same root
store rather than choosing between them, so this is a **superset** of
what was trusted before: a machine with an empty or unreadable OS store
behaves exactly as it did.

The lockfile picks up `rustls-native-certs` and its platform backends —
including `schannel`, which is what reads the Windows store where the
reporter's proxy CA lives.

## This widens what the CLI trusts

Stating it plainly: before this change the CLI trusted only the roots
compiled into the binary, so a CA injected into the local trust store
could not intercept it. After it, a root certificate installed on the
machine can intercept the CLI's traffic — which is precisely what the
reporter needs, because that is how their employer's proxy works. The
reasoning for accepting that trade-off is in longbridge/openapi#628; it
should be an explicit yes, not an incidental consequence.

## A performance change I tried and backed out

Trusting the OS store means `ClientBuilder::build()` reads the platform
trust store, and `rustls-native-certs` does not cache. Measured on
macOS, a `build()` goes from near-free to **95–169ms**. The CLI builds a
`reqwest::Client` in 18 places, so I wrote a shared
`rustls::ClientConfig` behind a `LazyLock` (build cost after the first:
**24–31µs**) and converted all 18 sites.

Then I counted how many clients a command actually builds through it:

| command | clients built |
|---|---|
| `quote 700.HK` | 0 |
| `watchlist` | 0 |
| `news 700.HK` | 0 |
| `statement list` | 0 |
| `--help` | 0 |

All 18 sites live in niche sub-commands — filing detail, topic detail,
SEC EDGAR, insider trades, statement download, update check, region
probe, OAuth registration — and a one-shot CLI process builds at most
one before exiting. The `serve` long-running mode dispatches only
quote/trade/api methods, which go through the SDK's shared client, not
these.

So the benefit was ~95ms on a handful of rarely used sub-commands, once
per process. Against that it added three direct dependencies, a new
module, 18 call-site changes, and two real problems:

- `use_preconfigured_tls` takes `impl Any`. Passing an
`Arc<ClientConfig>` where it downcasts to `ClientConfig` **compiled,
built, and ran** — it silently recorded an unknown backend and every
`build()` afterwards failed at runtime. Caught only by executing it.
- The hand-built config sets no ALPN, where reqwest sets `http/1.1`.
Measured: both still negotiate HTTP/1.1 against the gateway, but it is a
deviation, and the CLI also talks to third-party hosts.

Bad trade for a PR whose job is to trust the OS certificate store, so it
is out. **This PR is now the one-line feature change only.**

The SDK keeps the equivalent fixes in openapi#628, where the benefit is
real: the WebSocket connector is rebuilt on every reconnect, and the
OAuth token client on every refresh in a long-lived process.

## Scope — and why this alone does not fix the reporter

This covers the CLI's **own** HTTP clients. The CLI does not use one
stack: some steps build their own `reqwest::Client`, the rest go through
the SDK, which this repo takes from crates.io (`longbridge = "5.3.0"` —
there is no `[patch.crates-io]` on `main`). Traced through:

| step | client | fixed by this PR |
|---|---|---|
| `/oauth2/register` — **the reported failure** | CLI's own (`auth.rs`)
| ✅ |
| token refresh | CLI's own (`auth.rs`) | ✅ |
| `OAuthBuilder::build()` — code exchange | SDK `longbridge-oauth` | ❌ |
| quote / trade HTTP | SDK `longbridge-httpcli` | ❌ |
| quote / trade WebSocket | SDK `longbridge-wscli` | ❌ |

So merging this on its own moves the failure later rather than removing
it: `longbridge auth login` would get past registration and then fail in
the code exchange, and `longbridge quote` would still fail. **A clean
early error becomes a confusing late one**, which is worse than today.

For #1153 to actually be fixed for a user behind such a proxy, the order
has to be:

1. merge longbridge/openapi#628
2. **publish an SDK release containing it** — `main` is still at the
already-published 5.4.0, so this needs a version bump first
3. bump `longbridge` here (and in the MCP server) to that release
4. merge this and longbridge/longbridge-mcp#194

Step 2 is the real blocker, not the code in these PRs.

The same applies to the MCP server, which is on `longbridge = "5.3"`:
longbridge/longbridge-mcp#194.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
hogan-yuan added a commit to longbridge/longbridge-mcp that referenced this pull request Nov 19, 2026
…oots

Behind a corporate TLS-inspecting proxy every HTTPS call fails with
`invalid peer certificate: UnknownIssuer`, because reqwest was configured
with `rustls-tls` -- the bundled webpki roots and nothing else -- so the OS
trust store, where such a proxy installs its CA, was never consulted.

This is the same defect reported against the CLI in
longbridge/developers#1153. The SDK and the CLI are being fixed in
longbridge/openapi#628 and longbridge/longbridge-terminal#351; the MCP
server is the third entry point and had the same configuration, so a user
behind that proxy cannot run it either.

Enable `rustls-tls-native-roots` alongside `rustls-tls-webpki-roots`.
reqwest adds both sets to the same root store rather than choosing between
them, so this is a superset of what was trusted before: a machine with an
empty or unreadable OS store behaves exactly as it did.

This widens what the server trusts -- a root certificate installed on the
machine can now intercept its traffic. That is the point for the reporter's
case, and the reasoning for accepting it is set out in openapi#628.

No caching work is needed here, unlike the SDK: the OAuth proxy and the fx
tool already hold their clients in a `LazyLock`, and the only remaining
inline build is the authorization-code exchange, which runs once per
authentication.

Verified: a client built with the native roots alone reaches
openapi.longbridge.com, so the OS store is loaded and sufficient on its own.
The proxy case itself could not be reproduced here.

Note for a follow-up: this lockfile already resolved three different
webpki-roots versions (0.25.4, 0.26.11, 1.0.9) before this change. That is
pre-existing and untouched here.
hogan-yuan added a commit to longbridge/longbridge-mcp that referenced this pull request Nov 19, 2026
…oots (#194)

Behind a corporate TLS-inspecting proxy (Zscaler and the like) every
HTTPS call fails with `invalid peer certificate: UnknownIssuer`, while
other clients on the same machine reach the same endpoint fine.

Refs longbridge/developers#1153.

## Why this repo

The issue was reported against the CLI, but the cause is a dependency
configuration, not a product: `reqwest` was asked for `rustls-tls`,
which is `rustls-tls-webpki-roots` — the bundled root bundle and nothing
else. The OS trust store, where such a proxy installs its CA, was never
consulted, and no CA-bundle environment variable could add to it.

Three entry points shipped that same configuration. The MCP server is
the third, and the one users keep running:

| | PR |
|---|---|
| SDK | longbridge/openapi#628 |
| CLI | longbridge/longbridge-terminal#351 |
| **MCP** | **this one** |

**All three need to land for #1153 to actually be fixed.** Fixing only
the CLI would leave a user behind that proxy unable to run the MCP
server.

## Fix

Enable `rustls-tls-native-roots` alongside `rustls-tls-webpki-roots` —
one line in `Cargo.toml`. reqwest adds both sets to the same root store
rather than choosing between them, so this is a **superset** of what was
trusted before: a machine with an empty or unreadable OS store behaves
exactly as it did. The lockfile picks up `rustls-native-certs` and its
platform backends, including `schannel` for the Windows store.

## This widens what the server trusts

Before this change the server trusted only the roots compiled into the
binary, so a CA injected into the local trust store could not intercept
it. After it, a root certificate installed on the machine can intercept
the server's traffic — which is the point for the reporter's case,
because that is how their employer's proxy works. The reasoning for
accepting that trade-off is set out in openapi#628; it should be an
explicit yes.

## No caching work needed here, unlike the SDK

Trusting the OS store makes `ClientBuilder::build()` read the platform
trust store (~90ms, not cached by `rustls-native-certs`), so in the SDK
this came with fixes for clients that were rebuilt repeatedly — the
WebSocket connector on every reconnect, the OAuth token client on every
refresh.

I checked whether this repo has the same problem. It does not:

- `auth/oauth_proxy.rs` — client is in a `LazyLock`
- `tools/fx.rs` — client is in a `LazyLock`
- `tools/authenticate.rs` — builds inline, but only for the
authorization-code exchange, which runs once per authentication

So nothing here is worth restructuring, and I have not.

## Verification

A client built with the **native roots alone** reaches
`openapi.longbridge.com` (`Ok(404)`, the expected answer for `/`), so
the OS store is loaded and sufficient on its own and the feature is
doing what it says.

**What this does not prove:** the TLS-inspection case itself could not
be reproduced here — there is no such proxy on this machine. That the
fix resolves it follows from the proxy CA being in the OS store, which
the reporter confirmed by reaching the same endpoint with PowerShell on
the affected machine.

`cargo test`: 526 pass. `cargo clippy --all-targets`: same count as
`main`, no new findings.

## Note for a follow-up, not touched here

This lockfile already resolved **three** different `webpki-roots`
versions (0.25.4, 0.26.11, 1.0.9) before this change. That is
pre-existing — verified against `main` — and out of scope for a TLS
trust fix.

## This alone does not fix the reporter either

This repo depends on `longbridge = "5.3"` from crates.io, and the MCP
server's data path is the SDK, not its own clients. The three clients
fixed here are the OAuth proxy, the fx tool and the authorization-code
exchange; **everything a user actually calls the server for — quotes,
trades, the WebSocket — goes through the SDK**, which keeps the old root
set until a release carrying openapi#628 exists.

So the order has to be:

1. merge longbridge/openapi#628
2. **publish an SDK release containing it** — `main` there is still at
the already-published 5.4.0, so this needs a version bump first
3. bump `longbridge` here (and in the CLI) to that release
4. merge this and longbridge/longbridge-terminal#351

Step 2 is the real blocker, not the code in these PRs. Merging this one
early is harmless but does not make the server usable behind such a
proxy.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@hogan-yuan
hogan-yuan merged commit 5c8f5f6 into main Nov 19, 2026
56 checks passed
@hogan-yuan
hogan-yuan deleted the fix/tls-trust-os-root-store branch November 19, 2026 14:32
@hogan-yuan hogan-yuan mentioned this pull request Nov 20, 2026
hogan-yuan added a commit that referenced this pull request Nov 20, 2026
Moves `## [Unreleased]` to `## [5.5.0] - 2026-11-20` and bumps the
version. Nine lines; no code changes.

## Why this is needed now

`Cargo.toml` says `5.4.0`, and **5.4.0 is already published on
crates.io**. A release from `main` as it stands would be rejected at the
publish step, so nothing in `[Unreleased]` can ship until this lands.

That matters beyond the usual, because two things are waiting on it:

- **longbridge/developers#1153** (TLS behind an inspecting proxy) is
fixed in three places — #628 here,
longbridge/longbridge-terminal#351, longbridge/longbridge-mcp#194 — but
the CLI and the MCP server both take the SDK from crates.io (`longbridge
= "5.3"`). Their *own* HTTP clients are fixed; everything that goes
**through the SDK** keeps the old root set until a release carrying #628
exists. **Merging those three did not fix the reporter's problem; this
does.**
- `risk_assessment` is live on the gateway but absent from every
published SDK.

## The change

| | |
|---|---|
| `Cargo.toml` | 8 version strings: the workspace version and the 7
internal dependency requirements |
| `CHANGELOG.md` | 1 heading |

The internal requirements have to move with the workspace version —
`longbridge-geo`, `-wscli`, `-httpcli`, `-proto`, `-candlesticks`,
`-oauth` and `longbridge` itself all carry `version = "5.4.0"`, and
bumping only the workspace version would leave them resolving to the
previous release at publish time.

This is the same shape as the 5.3.0 release commit (`Cargo.toml | 16
++++----`, `CHANGELOG.md | 2 +-`), which is how I checked nothing was
missed: 8 occurrences found, 8 changed, 0 left.

## Why 5.5.0 and not 5.4.1

New API surface, nothing removed or renamed:

- `TradeContext.risk_assessment()` across all six SDK layers (#625)
- `OAuth.revoke()` / `OAuth.clear()` and typed OAuth error codes (#626)

The one behaviour change a caller could notice is that the authorization
flow no longer returns `CsrfTokenMismatch`. The variant still exists, so
code matching on it still compiles — it is a behaviour change, not a
compile break, and it is already described in the changelog.

## What ships in it

```
5c8f5f6  fix(tls): trust the OS certificate store in addition to the bundled roots (#628)
9b76c73  fix(trade): paginate history_orders and accept zero-padded HK symbols (#627)
19e7edf  fix(oauth): include error_description in authorization callback errors (#626)
c573bc6  feat(trade): add risk_assessment API (all layers) (#625)
```

Seven changelog entries, two of them marked `(security)` — the OAuth
callback page now HTML-escapes the error text, and `state` is checked on
error redirects too.

## Verified

`cargo check` resolves the whole workspace at the new version; `cargo
test -p longbridge` passes (88 + 57).

## After merge

The release runs off a push to the `release` branch. **I have not pushed
anything there** — that is for you to do.

One operational note from the 5.4.0 release, which is worth knowing
before you start it: that run **failed** on the Node.js aarch64 cross
build and was retried by pushing the fix (`782861d98`) to `release`,
which then succeeded. The retry worked because each crate's publish step
is guarded by `if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION`, so
crates already on crates.io are skipped rather than re-published. If
this run fails partway, re-running it is safe for the same reason — but
between the failure and the retry, some crates are published and others
are not.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
hogan-yuan added a commit to longbridge/longbridge-terminal that referenced this pull request Nov 23, 2026
Bumps `version` to `0.32.0`. One line in `Cargo.toml` plus the lockfile;
no code changes.

## Why 0.32.0 and not 0.31.3

This release adds a command, and the repo's precedent puts a new command
in the minor slot:

| version | what earned the bump |
|---|---|
| v0.31.0 | `feat(trade): route asset commands to US APIs for US
accounts` |
| v0.30.0 | `feat(quote): serve one-shot quote commands over HTTP REST`
|

`risk-assessment` is the same kind of change.

## Contents since v0.31.2

```
75f3b68 docs(valuation): explain high/low are fair-value band bounds (#354)
4954d57 feat(trade): add risk-assessment command (#350)
753cfef fix(auth): say when a token was encrypted for a different machine (#352)
e77245e fix(tls): trust the OS certificate store in addition to the bundled roots (#351)
ac6cf86 ci: cancel a pull request's superseded runs in test.yml (#353)
bddd70b chore: Build x86_64 Linux releases with cross to keep a baseline-CPU binary (#348)
52eb7a6 ai: Start a new conversation after signing in (#346)
```

Worth calling out:

- **TLS (#351)** — fixes `longbridge auth login` failing with `invalid
peer certificate: UnknownIssuer` behind a corporate TLS-inspecting proxy
(longbridge/developers#1153). **This widens what the CLI trusts**: a
certificate authority installed on the machine can now intercept its
traffic, which is what makes such a proxy work. Reasoning in
longbridge/openapi#628.
- **Auth diagnostics (#352)** — a token that cannot be decrypted now
says it was encrypted for a different machine, with the token path and
advice selected for the platform, instead of a bare "Failed to decrypt
auth token."

## Scope: two files only

`Cargo.toml` and `Cargo.lock`, matching the 0.31.2 bump (`263d9a5`,
which touched exactly those two). `.scoop/longbridge.json` also carries
a version, but `update-scoop.yml` rewrites it after the tag is published
— it is not part of the release commit.

## The SDK pin stays, deliberately

`[patch.crates-io]` still points `longbridge` at a git rev. It has to
for now: `longbridge 5.5.0` was tagged and released today but **is not
yet on crates.io**, and dropping the patch before it lands resolves to
5.4.0, which has no `risk_assessment` — `risk-assessment` (#350) would
not build.

**The follow-up matters more than this release.** Once 5.5.0 is on
crates.io: drop the patch and move to `longbridge = "5.5"`. That is what
carries the SDK-side TLS fix into the quote and trade paths. Until then
the CLI's **own** clients are fixed — which covers the
`/oauth2/register` failure actually reported — but
`OAuthBuilder::build()`, quotes and trades still go through the SDK on
the old root set, so longbridge/developers#1153 is not yet closed for
CLI users.

## Verified

`cargo test --bin longbridge`: 981 pass. `cargo check` clean.

## After merge

Tag `v0.32.0`; `update-scoop.yml` and `update-homebrew.yml` pick it up
from there.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
hogan-yuan added a commit to longbridge/longbridge-mcp that referenced this pull request Nov 23, 2026
Bumps `version` to `0.17.0`. One line in `Cargo.toml` plus the lockfile;
no code changes.

## Why 0.17.0 and not 0.16.6

This release adds a tool, and the repo's own precedent puts a new tool
in the minor slot:

| version | what earned the bump |
|---|---|
| v0.16.0 | `feat(tools): add get_me profile tool` |
| v0.15.0 | `feat(tools): add fx_rate backed by ECB reference rates` |

`risk_assessment` is the same kind of change.

## Contents since v0.16.5

```
307b345 fix(calc_indexes): return only requested indexes, null when unavailable (#200)
7fdfeeb fix(financial_statement): return the newest periods and trim line items (#199)
d016134 fix(financial_statement): require kind and drop the ALL fan-out (#197)
c9a33bf docs(valuation): describe low/high as fair-value band bounds (#196)
26afcd2 fix(tls): trust the OS certificate store in addition to the bundled roots (#194)
907c7b2 feat(tools): add risk_assessment tool (#193)
481ec37 ci: cancel a pull request's superseded runs (#195)
```

Two worth calling out:

- **`risk_assessment` (#193)** — the gateway endpoint has been live for
a while; this is the first release that exposes it here.
- **TLS (#194)** — fixes `invalid peer certificate: UnknownIssuer`
behind a corporate TLS-inspecting proxy, reported in
longbridge/developers#1153. **This widens what the server trusts**: a
certificate authority installed on the machine can now intercept its
traffic, which is what makes such a proxy work. The reasoning is in
longbridge/openapi#628.

## The SDK pin stays, deliberately

`[patch.crates-io]` still points `longbridge` at a git rev. It has to
for now: `longbridge 5.5.0` was tagged and released today but **is not
yet on crates.io**, and dropping the patch before it lands resolves to
5.4.0, which has no `risk_assessment` — the build would simply fail.

So this release ships built against a GitHub ref rather than a published
SDK. That is sound here because this repo publishes **binaries and
container images**, not a crate: nothing downstream resolves our
dependencies, and the rev is fetched at build time. (It is reachable:
the branch was deleted when longbridge/openapi#625 merged, but
`refs/pull/625/head` keeps the commit, and a clean-`CARGO_HOME` resolve
against it was verified.)

**The follow-up matters more than this release.** Once 5.5.0 is on
crates.io: drop the patch, move to `longbridge = "5.5"`. That is what
carries the SDK-side TLS fix into the data path — quotes, trades, the
WebSocket. Until then this server's **own** clients are fixed but
anything going through the SDK still uses the old root set, so
longbridge/developers#1153 is not yet closed for MCP users.

## Verified

`cargo test`: 531 pass, 2 ignored. `cargo check` clean.

## After merge

Tag `v0.17.0` on the release commit, as with `v0.16.5`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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