Skip to content

test: renew the expired server certificate, add a podman/docker test-server script - #430

Open
joelparkerhenderson wants to merge 1 commit into
tiberius-rs:mainfrom
joelparkerhenderson:test-server-podman
Open

test: renew the expired server certificate, add a podman/docker test-server script#430
joelparkerhenderson wants to merge 1 commit into
tiberius-rs:mainfrom
joelparkerhenderson:test-server-podman

Conversation

@joelparkerhenderson

@joelparkerhenderson joelparkerhenderson commented Aug 24, 2026

Copy link
Copy Markdown

I'm human. During my Rust work, this issue below came up during AI automatic review. The issue report below is by Claude. Happy to explain more if that can help. -Joel

The problem

docker/certs/server.crt expired on 2024-12-20.

$ openssl x509 -in docker/certs/server.crt -noout -dates
notBefore=Jun  3 11:40:33 2024 GMT
notAfter=Dec 20 11:40:33 2024 GMT

Every image built from docker/ since then presents an expired certificate. The server starts fine and reports the certificate loaded successfully, so nothing looks wrong from its side — but the client aborts the handshake, and the entire server-dependent suite fails with:

Error: Tls("connection closed via error")

That reads like a client or configuration bug rather than a stale fixture, which makes it an expensive thing to walk into. It is currently the first thing a new contributor hits when they try to run the tests.

The fix

Regenerated with this repository's own docker/certs/generate-signed-cert.sh, unchanged:

notBefore=Aug 24 08:49:53 2026 GMT
notAfter=Mar 12 08:49:53 2027 GMT

The customCA is untouched and remains valid until 2027-11-14, so only the leaf is renewed and anything already trusting the CA keeps working. openssl verify -CAfile customCA.crt server.crt passes.

The script mints 200-day certificates, so this will lapse again around March 2027. Worth a calendar note, or a CI job that fails when the leaf is within a month of expiry — happy to add the latter here if you want it.

Also: docker/test-server.sh

A small script that brings a server up under podman or docker, since there was no one-liner for this:

./docker/test-server.sh up
export TIBERIUS_TEST_CONNECTION_STRING='server=tcp:localhost,1433;user=SA;password=<YourStrong@Passw0rd>;IntegratedSecurity=true;TrustServerCertificate=true'
cargo test
./docker/test-server.sh down

It picks podman if present, otherwise docker, and both engine and image are overridable (ENGINE=docker IMAGE=mssql-2022 ./docker/test-server.sh up).

Two decisions worth explaining:

  • It defaults to azure-sql-edge. The full SQL Server images are x86_64 only, so on arm64 (Apple silicon) they refuse to run or run slowly under emulation. The edge image is the one that works on both, and this repo already had a dockerfile for it.
  • It polls the log, not the port. 1433 accepts connections well before the server will answer, so a port check reports ready too early and the first test fails.

docker-compose.yml is left alone — this is additive.

Verification

With the certificate renewed, against a server built by this script:

cargo test --tests --no-default-features \
  --features "tds73,rustls,sql-browser-tokio,chrono,time,rust_decimal"

390 passed, 0 failed

One thing I did not fix

With the renewed certificate the suite passes under --features rustls, but still fails under the default native-tls on macOS with the same Tls("connection closed via error"). The server log shows no complaint, so the rejection is client-side in Security.framework. I did not chase it down and it is out of scope here — but it means a macOS contributor running plain cargo test will still see failures after this PR, and I would rather say so than let it look fixed.

…server script

docker/certs/server.crt expired on 2024-12-20. Every image built from
docker/ since then has presented an expired certificate, so the TLS
handshake fails and the whole server-dependent suite fails with
Tls("connection closed via error") — which reads like a client bug rather
than a stale fixture.

Regenerated with the repository's own certs/generate-signed-cert.sh. The
customCA is untouched and still valid until 2027-11-14; only the leaf is
renewed, so nothing that trusts the CA needs updating.

Also adds docker/test-server.sh, which builds, starts and waits for a
server with either podman or docker:

    ./docker/test-server.sh up
    export TIBERIUS_TEST_CONNECTION_STRING='server=tcp:localhost,1433;user=SA;password=<YourStrong@Passw0rd>;IntegratedSecurity=true;TrustServerCertificate=true'
    cargo test

It defaults to the azure-sql-edge image because the full SQL Server images
are x86_64 only, so on arm64 they refuse to run or run under emulation.
It polls the log for readiness rather than the port, because the port
accepts connections well before the server answers.

Verified: 390 tests pass against a server built by this script.
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e075b9ec-fa4a-4433-991b-3bfc7d9b66ab

📥 Commits

Reviewing files that changed from the base of the PR and between a6b4fcd and 5d8bb45.

⛔ Files ignored due to path filters (1)
  • docker/certs/server.pem is excluded by !**/*.pem
📒 Files selected for processing (5)
  • docker/certs/customCA.srl
  • docker/certs/server-full.crt
  • docker/certs/server.crt
  • docker/certs/server.key
  • docker/test-server.sh

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Summary by CodeRabbit

  • New Features

    • Added a utility for starting, stopping, and viewing logs from the SQL Server test container.
    • Supports Docker and Podman, configurable connection settings, readiness checks, and timeout diagnostics.
  • Chores

    • Renewed the local server certificates and corresponding private key.
    • Updated certificate serial information for local development and testing.

Walkthrough

The change renews the server certificate chain, private key, and certificate serial metadata. It adds a Bash utility that builds and runs a SQL Server test container through Podman or Docker. The utility supports configurable settings, readiness polling, failure diagnostics, container removal, and log following.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes both primary changes: renewing the expired certificate and adding the Podman/Docker test-server script.
Description check ✅ Passed The description directly explains the certificate renewal, test-server script, verification results, and remaining native TLS limitation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

MattJackson referenced this pull request in MattJackson/tiberius-ng Aug 29, 2026
Additive helper from upstream #430 (author Joel Parker Henderson): brings a
SQL Server container up under podman or docker, defaults to arm64-friendly
azure-sql-edge, and polls the log for readiness. (The cert-renewal part of
#430 is already covered by #419.)
joelparkerhenderson added a commit to mssql-rust/mssql-rust that referenced this pull request Aug 29, 2026
Mirrors the non-cert-renewal half of tiberius-rs/tiberius#430. The
cert-renewal half is moot here -- this fork's docker/certs/server.crt
was already regenerated with a 5-year validity in ea6bb6a -- so only
the new script is added, ported to this fork's mssql crate name and
MSSQL_TEST_CONNECTION_STRING (was TIBERIUS_TEST_CONNECTION_STRING).

`./docker/test-server.sh up|down|logs` builds and starts a local SQL
Server via podman or docker (auto-detected, podman preferred),
defaulting to azure-sql-edge for cross-arch (x86_64/arm64) portability,
and polls the container log for the ready message rather than the
socket (the port opens well before the server will answer).

Verified end to end, not just started: ran it against a real container
and used it to run 276 tests (196 in tests/query.rs, 80 in
tests/bulk.rs) against a live SQL Server via the rustls feature, which
is also how two real bugs were found and fixed in the two preceding
commits.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
joelparkerhenderson added a commit to mssql-rust/mssql-rust that referenced this pull request Aug 30, 2026
Mirrors the non-cert-renewal half of tiberius-rs/tiberius#430. The
cert-renewal half is moot here -- this fork's docker/certs/server.crt
was already regenerated with a 5-year validity in 430202d -- so only
the new script is added, ported to this fork's mssql crate name and
MSSQL_TEST_CONNECTION_STRING (was TIBERIUS_TEST_CONNECTION_STRING).

`./docker/test-server.sh up|down|logs` builds and starts a local SQL
Server via podman or docker (auto-detected, podman preferred),
defaulting to azure-sql-edge for cross-arch (x86_64/arm64) portability,
and polls the container log for the ready message rather than the
socket (the port opens well before the server will answer).

Verified end to end, not just started: ran it against a real container
and used it to run 276 tests (196 in tests/query.rs, 80 in
tests/bulk.rs) against a live SQL Server via the rustls feature, which
is also how two real bugs were found and fixed in the two preceding
commits.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
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