Skip to content

mysql: add TLS server name override for SNI - #4130

Merged
abonander merged 4 commits into
transact-rs:mainfrom
mingley:mysql-tls-server-name-override
Oct 27, 2026
Merged

abonander merged 4 commits into
transact-rs:mainfrom
mingley:mysql-tls-server-name-override

Conversation

@mingley

@mingley mingley commented Dec 19, 2025 •

Copy link
Copy Markdown
Contributor

Summary

  • add a tls_server_name override to MySqlConnectOptions
  • use the override for TLS SNI and hostname verification during the MySQL TLS upgrade handshake
  • add a small unit test + docs for the new option

Problem

VerifyIdentity ties both TLS SNI and certificate hostname verification to the TCP host value. In
real deployments (e.g., HAProxy or multi-instance pools), clients often connect via an IP or
internal alias that does not match the server certificate’s DNS name. This causes TLS verification
failures even when the CA and certificate are correct.

Rationale

This change lets users explicitly specify the TLS server name used for SNI + hostname verification
while keeping the TCP host unchanged. It is additive and opt-in: existing behavior is unchanged
unless the new option is set.

Testing

  • cargo fmt
  • cargo clippy -p sqlx-mysql -- -D warnings
  • cargo test -p sqlx-mysql
  • local integration test against a HAProxy-fronted MySQL-compatible endpoint (e.g., TiDB) with VerifyIdentity enabled; connection + simple query succeeded using the SNI override

@mingley
mingley force-pushed the mysql-tls-server-name-override branch from 4a575f4 to 4f94625 Compare February 6, 2026 18:37
@mingley
mingley force-pushed the mysql-tls-server-name-override branch from 5879718 to 9fe7ff1 Compare June 22, 2026 23:13
@abonander
abonander merged commit 242eb8c into transact-rs:main Oct 27, 2026
147 checks passed
markharding pushed a commit to futo-org/Harbor that referenced this pull request Nov 24, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [sqlx](https://github.com/launchbadge/sqlx) | dependencies | patch | `0.9.0` → `0.9.1` |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/2097) for more information.

---

### Release Notes

<details>
<summary>launchbadge/sqlx (sqlx)</summary>

### [`v0.9.1`](https://github.com/launchbadge/sqlx/blob/HEAD/CHANGELOG.md#091---2026-11-17)

[Compare Source](transact-rs/sqlx@v0.9.0...v0.9.1)

##### AI Policy Announcement

Prompted by  a recent uptick in AI-generated pull requests, we added an [`AI_POLICY.md`](./AI_POLICY.md) to clarify our position
on AI-generated contributions. This is not strictly a new policy, but a codification of existing sentiment among the
maintainers and community.

TL;DR: the use of generative AI is **not** expressly prohibited, but there's a few big things that will not be accepted
(note that this list is not exhaustive):

- Issues and pull requests authored primarily or entirely by agents like Claude Code.
- Comments and interactions that are clearly AI generated.
- Commits authored by or attributed to Claude or other agents.
- PRs that duplicate the effort of other existing pull requests without acknowledging them.

See also [#&#8203;4472] for motivation and discussion.

##### Added

- \[[#&#8203;4080]]: feat(sqlite): expose thread_stack_size option \[\[[@&#8203;ZenasSong](https://github.com/ZenasSong)]]
- \[[#&#8203;4130]]: mysql: add TLS server name override for SNI \[\[[@&#8203;mingley](https://github.com/mingley)]]
- \[[#&#8203;4295]]: Add Infinity check functions to `PgInterval` \[\[[@&#8203;firebladed](https://github.com/firebladed)]]
- \[[#&#8203;4334]]: feat: add ability to set or unset the CLIENT_FOUND_ROWS flag \[\[[@&#8203;andreastedile](https://github.com/andreastedile)]]
- \[[#&#8203;4475]]: feat(tls): support native roots with the rustls AWS-LC backend \[\[[@&#8203;markuskobler](https://github.com/markuskobler)]]
  - Adds `tls-rustls-aws-lc-rs-native-roots` feature.
- \[[#&#8203;4478]]: feat: add Type for MySQL, Sqlite, and Any byte arrays \[\[[@&#8203;daimond113](https://github.com/daimond113)]]

##### Changed

- \[[#&#8203;4242]]: Reuse the TLS connector across connection attempts \[\[[@&#8203;goffrie](https://github.com/goffrie)]]
- \[[#&#8203;4263]]: sqlx-cli: drop the literal style override that was invisible on light terminals \[\[[@&#8203;c-tonneslan](https://github.com/c-tonneslan)]]
- \[[#&#8203;4264]]: chore: Add README to examples \[\[[@&#8203;szabgab](https://github.com/szabgab)]]
- \[[#&#8203;4278]]: docs: document sqlx test connection limits \[\[[@&#8203;angelnereira](https://github.com/angelnereira)]]
- \[[#&#8203;4344]]: docs(postgres): document default TimeZone=UTC session behavior \[\[[@&#8203;jeremie0342](https://github.com/jeremie0342)]]
- \[[#&#8203;4345]]: docs(macros): document that bind parameter nullability is not compile-checked \[\[[@&#8203;jeremie0342](https://github.com/jeremie0342)]]
- \[[#&#8203;4367]]: Error on .sql migration files that don't match the expected filename format \[\[[@&#8203;teddytennant](https://github.com/teddytennant)]]
- \[[#&#8203;4377]]: Update README.md versions to 0.9 \[\[[@&#8203;Voklen](https://github.com/Voklen)]]
- \[[#&#8203;4388]]: Replace license symlinks with copies \[\[[@&#8203;WaterWhisperer](https://github.com/WaterWhisperer)]]
- \[[#&#8203;4392]]: Improve sqlx prepare invocation error \[\[[@&#8203;mameikagou](https://github.com/mameikagou)]]
- \[[#&#8203;4398]]: docs: clarify `Pool::size` and `Pool::num_idle` \[\[[@&#8203;valentynkit](https://github.com/valentynkit)]]
- \[[#&#8203;4402]]: sqlx-sqlite: relax libsqlite3-sys constraint to allow 0.38.x \[\[[@&#8203;dtolnay](https://github.com/dtolnay)]]
- \[[#&#8203;4472]]: doc: add `AI_POLICY.md` \[\[[@&#8203;abonander](https://github.com/abonander)]]
- \[[#&#8203;4502]]: Bump the upper bound on libsqlite3-sys to allow 0.39.x \[\[[@&#8203;joshtriplett](https://github.com/joshtriplett)]]
- \[[#&#8203;4514]]: fix(postgres): make `hostaddr` semantics match `libpq` \[\[[@&#8203;abonander](https://github.com/abonander)]]
  - Minor breaking behavior change: `hostaddr`(env: `PGHOSTADDR`) is no longer treated as a simple alias for `host`.
  - It bypasses DNS resolution but `host` is still used for TLS Server Name Identification (SNI), if applicable.
  - This is considered a bugfix because this now matches `libpq`'s behavior as promised in the docs.

##### Fixed

- \[[#&#8203;4016]]: Fix PgListener::try_recv \[\[[@&#8203;PonasKovas](https://github.com/PonasKovas)]]
- \[[#&#8203;4205]]: bugfix: streamline and fix AnyQueryResult::last_insert_id() for SQLite \[\[[@&#8203;migus-rs](https://github.com/migus-rs)]]
- \[[#&#8203;4282]]: fix(macros): don't look for `.env` outside workspace \[\[[@&#8203;abonander](https://github.com/abonander)]]
- \[[#&#8203;4286]]: Fix query macros against CockroachDB by gating plan_cache_mode on EXPLAIN support \[\[[@&#8203;BastienClement](https://github.com/BastienClement)]]
- \[[#&#8203;4289]]: fix(pool): prevent num_idle underflow that wedges maintenance in a CPU spin \[\[[@&#8203;nipunn1313](https://github.com/nipunn1313)]]
- \[[#&#8203;4301]]: fix(deps): align sqlx-core and sqlx-macros-core on workspace sha2 \[\[[@&#8203;waamm](https://github.com/waamm)]]
- \[[#&#8203;4303]]: fix: whoami regression to anonymous user \[\[[@&#8203;lsunsi](https://github.com/lsunsi)]]
- \[[#&#8203;4306]]: fix(sqlite): return 0 for changes if statement is read-only \[\[[@&#8203;waamm](https://github.com/waamm)]]
- \[[#&#8203;4317]]: fix(sqlite): migrate datetime format builders off time 0.3.48-depreca… \[\[[@&#8203;LiamCarPer](https://github.com/LiamCarPer)]]
- \[[#&#8203;4336]]: perf: enable TCP_NODELAY on sockets \[\[[@&#8203;dmitryvk](https://github.com/dmitryvk)]]
- \[[#&#8203;4337]]: Fix PostgreSQL memory leak when statement cache is disabled \[\[[@&#8203;deathlesz](https://github.com/deathlesz)]]
- \[[#&#8203;4340]]: fix(sqlite): correct sub-second decoding of pre-epoch REAL datetimes \[\[[@&#8203;zelinewang](https://github.com/zelinewang)]]
- \[[#&#8203;4359]]: Fix Any type/close handling, MySQL time signs, SQLite plans, and macro docs \[\[[@&#8203;WaterWhisperer](https://github.com/WaterWhisperer)]]
- \[[#&#8203;4361]]: fix(postgres): re-parse unnamed statement after resolving custom-type OIDs \[\[[@&#8203;DoTuanAnh2k1](https://github.com/DoTuanAnh2k1)]]
- \[[#&#8203;4371]]: fix(macros): tolerate unreadable dotenv with query source \[\[[@&#8203;Boulea7](https://github.com/Boulea7)]]
- \[[#&#8203;4374]]: fix(sqlite): don't dereference a NULL declared type in column_nullable \[\[[@&#8203;msdrigg](https://github.com/msdrigg)]]
- \[[#&#8203;4375]]: \[PostgreSQL] Invalided stale prepared statements \[\[[@&#8203;Flassie](https://github.com/Flassie)]]
- \[[#&#8203;4394]]: fix(postgres): roll back a transaction cancelled during BEGIN \[\[[@&#8203;rubenfiszel](https://github.com/rubenfiszel)]]
- \[[#&#8203;4406]]: fix(postgres): return UnexpectedEof when server closes connection at SSLRequest \[\[[@&#8203;zfaustk](https://github.com/zfaustk)]]
- \[[#&#8203;4413]]: Fix incorrect example path and migration filename in docs \[\[[@&#8203;toyeshhm](https://github.com/toyeshhm)]]
- \[[#&#8203;4433]]: fix(sqlite): return an error instead of panicking when decoding an out-of-range INTEGER as PrimitiveDateTime \[\[[@&#8203;breken-ai](https://github.com/breken-ai)]]
- \[[#&#8203;4436]]: fix(mysql): use the AuthSwitchRequest nonce for caching_sha2_password full auth \[\[[@&#8203;LeandroDettmer](https://github.com/LeandroDettmer)]]
- \[[#&#8203;4439]]: fix(macros-core): only track paths rustc can checksum \[\[[@&#8203;varunshahdev](https://github.com/varunshahdev)]]
- \[[#&#8203;4441]]: fix(mysql): decode MySQL 9 VECTOR columns (type 0xf2) \[\[[@&#8203;anderson-andres-dev](https://github.com/anderson-andres-dev)]]
- \[[#&#8203;4442]]: fix(sqlite): await SQLCipher test connection cleanup before exit \[\[[@&#8203;shuvroroy](https://github.com/shuvroroy)]]
- \[[#&#8203;4450]]: fix(tls): don't wait for incoming data in `RustlsSocket::poll_flush()` \[\[[@&#8203;Tango-Ninja](https://github.com/Tango-Ninja)]]
- \[[#&#8203;4458]]: fix(mysql): harden protocol decoders against malformed packets from hostile servers \[\[[@&#8203;portlandhodl](https://github.com/portlandhodl)]]
- \[[#&#8203;4463]]: fix(macros): only report Ambiguous{DateTime,Numeric}Type when preferred crate is Inferred \[\[[@&#8203;rscorer](https://github.com/rscorer)]]
- \[[#&#8203;4473]]: fix(sqlite): synchronize transaction depth when SQLite auto-rolls back \[\[[@&#8203;webdevsamran](https://github.com/webdevsamran)]]
- \[[#&#8203;4477]]: fix(postgres): Bind encodes result-format count from the wrong field \[\[[@&#8203;prostomarkeloff](https://github.com/prostomarkeloff)]]
- \[[#&#8203;4485]]: fix(postgres): ignore notifications on connections that aren't listening.  fixes [#&#8203;4484](transact-rs/sqlx#4484). \[\[[@&#8203;luketpeterson](https://github.com/luketpeterson)]]
- \[[#&#8203;4488]]: fix(postgres): preserve quoted "NULL" elements when decoding text arrays \[\[[@&#8203;MinJaeRun](https://github.com/MinJaeRun)]]
- \[[#&#8203;4493]]: fix(mysql): handle empty passwords during authentication switches. \[\[[@&#8203;lmont19](https://github.com/lmont19)]]
- \[[#&#8203;4496]]: fix(mysql): quote charset/collation/time_zone in connect-time SET \[\[[@&#8203;Nacl-HCl](https://github.com/Nacl-HCl)]]
- \[[#&#8203;4498]]: fix(postgres): keep draining resolved type dependencies in fill_cache \[\[[@&#8203;ducnhan123-co](https://github.com/ducnhan123-co)]]
- \[[#&#8203;4503]]: fix(mysql): decode DECIMAL columns into integer types correctly \[\[[@&#8203;Map130](https://github.com/Map130)]]
- \[[#&#8203;4508]]: fix(macros): reject `#[repr(C)]` on enums in `derive(Type)` \[\[[@&#8203;thelastbackspace](https://github.com/thelastbackspace)]]
- \[[#&#8203;4525]]: sqlx-sqlite: bump the upper bound on libsqlite3-sys to allow 0.40.x \[\[[@&#8203;lthiery](https://github.com/lthiery)]]
- \[[#&#8203;4526]]: docs(FAQ): Replace versioned docs.rs link with latest \[\[[@&#8203;TheJanzap](https://github.com/TheJanzap)]]
- \[[#&#8203;4528]]: fix(postgres): don't panic decoding out-of-range dates and times \[\[[@&#8203;colinhacks](https://github.com/colinhacks)]]
- \[[#&#8203;4529]]: fix: handle IPv6 properly at all levels \[\[[@&#8203;abonander](https://github.com/abonander)]]
  - IPv6 addresses are now properly supported in URLs (e.g. `postgres://user:password@[::1]:5432/database`)
    and passed to the TLS layer for IP-based Server Name Identification (SNI), if applicable.
  - Note: renamed unreleased `MySqlConnectOptions::tls_servername()` to `tls_sni_servername`
    to match the option added to the MySQL C API. Also added `tls-sni-servername` as a URL parameter.

[#&#8203;4016]: transact-rs/sqlx#4016

[#&#8203;4080]: transact-rs/sqlx#4080

[#&#8203;4130]: transact-rs/sqlx#4130

[#&#8203;4205]: transact-rs/sqlx#4205

[#&#8203;4242]: transact-rs/sqlx#4242

[#&#8203;4263]: transact-rs/sqlx#4263

[#&#8203;4264]: transact-rs/sqlx#4264

[#&#8203;4278]: transact-rs/sqlx#4278

[#&#8203;4282]: transact-rs/sqlx#4282

[#&#8203;4286]: transact-rs/sqlx#4286

[#&#8203;4289]: transact-rs/sqlx#4289

[#&#8203;4295]: transact-rs/sqlx#4295

[#&#8203;4301]: transact-rs/sqlx#4301

[#&#8203;4303]: transact-rs/sqlx#4303

[#&#8203;4306]: transact-rs/sqlx#4306

[#&#8203;4317]: transact-rs/sqlx#4317

[#&#8203;4334]: transact-rs/sqlx#4334

[#&#8203;4336]: transact-rs/sqlx#4336

[#&#8203;4337]: transact-rs/sqlx#4337

[#&#8203;4340]: transact-rs/sqlx#4340

[#&#8203;4344]: transact-rs/sqlx#4344

[#&#8203;4345]: transact-rs/sqlx#4345

[#&#8203;4359]: transact-rs/sqlx#4359

[#&#8203;4361]: transact-rs/sqlx#4361

[#&#8203;4367]: transact-rs/sqlx#4367

[#&#8203;4371]: transact-rs/sqlx#4371

[#&#8203;4374]: transact-rs/sqlx#4374

[#&#8203;4375]: transact-rs/sqlx#4375

[#&#8203;4377]: transact-rs/sqlx#4377

[#&#8203;4388]: transact-rs/sqlx#4388

[#&#8203;4392]: transact-rs/sqlx#4392

[#&#8203;4394]: transact-rs/sqlx#4394

[#&#8203;4398]: transact-rs/sqlx#4398

[#&#8203;4402]: transact-rs/sqlx#4402

[#&#8203;4406]: transact-rs/sqlx#4406

[#&#8203;4413]: transact-rs/sqlx#4413

[#&#8203;4433]: transact-rs/sqlx#4433

[#&#8203;4436]: transact-rs/sqlx#4436

[#&#8203;4439]: transact-rs/sqlx#4439

[#&#8203;4441]: transact-rs/sqlx#4441

[#&#8203;4442]: transact-rs/sqlx#4442

[#&#8203;4450]: transact-rs/sqlx#4450

[#&#8203;4473]: transact-rs/sqlx#4473

[#&#8203;4458]: transact-rs/sqlx#4458

[#&#8203;4463]: transact-rs/sqlx#4463

[#&#8203;4472]: transact-rs/sqlx#4472

[#&#8203;4475]: transact-rs/sqlx#4475

[#&#8203;4477]: transact-rs/sqlx#4477

[#&#8203;4478]: transact-rs/sqlx#4478

[#&#8203;4485]: transact-rs/sqlx#4485

[#&#8203;4488]: transact-rs/sqlx#4488

[#&#8203;4493]: transact-rs/sqlx#4493

[#&#8203;4496]: transact-rs/sqlx#4496

[#&#8203;4498]: transact-rs/sqlx#4498

[#&#8203;4502]: transact-rs/sqlx#4502

[#&#8203;4503]: transact-rs/sqlx#4503

[#&#8203;4508]: transact-rs/sqlx#4508

[#&#8203;4514]: transact-rs/sqlx#4514

[#&#8203;4525]: transact-rs/sqlx#4525

[#&#8203;4526]: transact-rs/sqlx#4526

[#&#8203;4528]: transact-rs/sqlx#4528

[#&#8203;4529]: transact-rs/sqlx#4529

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 9am on tuesday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNTIuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjI1Mi4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

Co-authored-by: Thomas de Zeeuw <[email protected]>
Reviewed-on: https://code.futo.org/harbor/harbor/pulls/2477
Reviewed-by: Thomas de Zeeuw <[email protected]>
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.

2 participants