microsoft / go-sqlcmd

The new sqlcmd, CLI for SQL Server and Azure SQL (winget install sqlcmd / sqlcmd create mssql / sqlcmd open ads)
https://learn.microsoft.com/sql/tools/sqlcmd/go-sqlcmd-utility
MIT License
323 stars 56 forks source link

Add -N strict option #459

Closed apoorvdeshmukh closed 9 months ago

apoorvdeshmukh commented 10 months ago

Fixes #430

Validation: With unknown CA

git\go-sqlcmd>.\sqlcmd.exe -Slocalhost:1434 -Usa -P<masked> -N "strict"
TLS Handshake failed: tls: failed to verify certificate: x509: certificate signed by unknown authority
TLS Handshake failed: tls: failed to verify certificate: x509: certificate signed by unknown authority

git\go-sqlcmd>.\sqlcmd.exe -Slocalhost:1434 -Usa -P<masked> -N "strict" -C
TLS Handshake failed: tls: failed to verify certificate: x509: certificate signed by unknown authority
TLS Handshake failed: tls: failed to verify certificate: x509: certificate signed by unknown authority

With known CA

git\go-sqlcmd>.\sqlcmd.exe -S<redacted>.database.windows.net:1433 -U<masked> -P<masked> -N "strict"
1> select @@version
2> go

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Azure (RTM) - 12.0.2000.8
        Jul 17 2023 18:40:52
        Copyright (C) 2022 Microsoft Corporation

(1 row affected)
1> SELECT protocol_type, CONVERT(varbinary(9),protocol_version),client_net_address from sys.dm_exec_connections where session_id=@@SPID
2> go
protocol_type                                      client_net_address
---------------------------------------- --------- ------------------------------------------------
TSQL                                     0x0800000 58.84.60.222

(1 row affected)
1> exit