Skip to content

Support trust_server_certificate option in dbconsole#1383

Open
justindell wants to merge 1 commit intorails-sqlserver:8-1-stablefrom
justindell:trust-server-certificate-dbconsole
Open

Support trust_server_certificate option in dbconsole#1383
justindell wants to merge 1 commit intorails-sqlserver:8-1-stablefrom
justindell:trust-server-certificate-dbconsole

Conversation

@justindell
Copy link
Contributor

Summary

  • Pass -C (TrustServerCertificate) flag to sqlcmd when trust_server_certificate: true is set in database.yml
  • Fixes rails dbconsole failing with ODBC Driver 18+ against SQL Server instances using self-signed certificates (e.g. Docker)

Problem

Starting with ODBC Driver 18, Microsoft encrypts connections by default and validates SSL certificates. Local SQL Server instances (e.g. Docker) use self-signed certificates, which causes rails dbconsole to fail with:

Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : SSL Provider:
[error:0A000086:SSL routines::certificate verify failed:self-signed certificate].

The Rails app itself connects fine because TinyTds/FreeTDS handles TLS differently, but dbconsole shells out to sqlcmd directly and had no mechanism to pass the -C flag.

Usage

development:
  adapter: sqlserver
  host: localhost
  database: myapp_development
  username: sa
  password: secret
  trust_server_certificate: true

Changes

  • sqlserver_adapter.rb: One new line to pass -C when trust_server_certificate is set
  • test/cases/dbconsole.rb: Updated test to cover the new flag (also fixed pre-existing OracleEnhancedAdapter reference and sqlplus description)

ODBC Driver 18+ encrypts connections by default and validates SSL
certificates, causing `rails dbconsole` to fail against SQL Server
instances using self-signed certificates (e.g. Docker). Pass the -C
flag to sqlcmd when trust_server_certificate is set in database.yml.
@justindell justindell force-pushed the trust-server-certificate-dbconsole branch from 32fe8cf to 6731fb6 Compare March 18, 2026 19:01
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