Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: support mssql to use system cert (#13099)

h3n4le41b09c9218c
diff --git a/backend/plugin/db/mssql/mssql.go b/backend/plugin/db/mssql/mssql.go
index c62d0a84b6..d35bfcd285 100644
--- a/backend/plugin/db/mssql/mssql.go
+++ b/backend/plugin/db/mssql/mssql.go
@@ -64,11 +64,11 @@ func (driver *Driver) Open(_ context.Context, _ storepb.Engine, config db.Connec
trustServerCertificate := "true"
var err error
- if config.TLSConfig.SslCA != "" {
+ if config.TLSConfig.UseSSL && config.TLSConfig.SslCA != "" {
// We should not TrustServerCertificate in production environment, otherwise, TLS is susceptible
// to man-in-the middle attacks. TrustServerCertificate makes driver accepts any certificate presented by the server
// and any host name in that certificate.
- // Due to Golang runtime limitation, x509 package will throw the error of 'certificate relies on legacy Common Name field, use SANs instead' if
+ // Due to Golang runtime limitation, x509 package will throw the error of 'certificate relies on legacy Common Name field, use SANs instead if
// TrustServerCertificate is false.
trustServerCertificate = "false"
// Driver reads the certificate from file instead of regarding it as certificate content.
diff --git a/go.mod b/go.mod
index bc952f21ae..69e3cfd6c5 100644
--- a/go.mod
+++ b/go.mod
@@ -337,6 +337,6 @@ replace (
github.com/beltran/gosasl => github.com/bytebase/gosasl v0.0.0-20240422091407-6b7481e86f08
)
-replace github.com/microsoft/go-mssqldb => github.com/bytebase/go-mssqldb v0.0.0-20240613094500-7f9ca9381f8f
+replace github.com/microsoft/go-mssqldb => github.com/bytebase/go-mssqldb v0.0.0-20240801091126-3ff3ca07d898
replace github.com/youmark/pkcs8 => github.com/bytebase/pkcs8 v0.0.0-20240612095628-fcd0a7484c94
diff --git a/go.sum b/go.sum
index 0938e2495e..af80f041a5 100644
--- a/go.sum
+++ b/go.sum
@@ -784,8 +784,8 @@ github.com/bytebase/gh-ost2 v0.0.0-20240731091141-e7a12a9401ab h1:hJ3tfjfm5D63Qw
github.com/bytebase/gh-ost2 v0.0.0-20240731091141-e7a12a9401ab/go.mod h1:VRPqaDM7UYxJbcCtQkjBcNkxW17p6LJJdkM/nYwQhqg=
github.com/bytebase/go-lsp v0.0.0-20240130071507-c04b5c75010c h1:W832GNANCst4C6TgYbQnKKxbuMZKQxTD4++b3HOuzBo=
github.com/bytebase/go-lsp v0.0.0-20240130071507-c04b5c75010c/go.mod h1:SULmZY7YNBsvNiQbrb/BEDdEJ84TGnfyUQxaHt8t8rY=
-github.com/bytebase/go-mssqldb v0.0.0-20240613094500-7f9ca9381f8f h1:hcjpjIaVVPuZOrHvkXiu7HDSow03aDdK+fXTZM6g93c=
-github.com/bytebase/go-mssqldb v0.0.0-20240613094500-7f9ca9381f8f/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA=
+github.com/bytebase/go-mssqldb v0.0.0-20240801091126-3ff3ca07d898 h1:0ggqA9XL4yvtePPvRDRYMed3jtdNk4s0o8AMW8uJPSA=
+github.com/bytebase/go-mssqldb v0.0.0-20240801091126-3ff3ca07d898/go.mod h1:2KhUz4GSLcdJGXSJMXAf2BjmakcgoOkNyPpHdGAxRpY=
github.com/bytebase/go-obo v0.0.0-20231026081615-705a7fffbfd2 h1:nEHZi8S7PHT4GxP9GfJiuhO8KkYcHmePvy5BfiYxwNk=
github.com/bytebase/go-obo v0.0.0-20231026081615-705a7fffbfd2/go.mod h1:wjDx6Xm9q7dFtHJvIlrI99JytznLw5wQ4R+9mNXJwGI=
github.com/bytebase/gohive v0.0.0-20240422092929-d76993a958a4 h1:5o+GWOu+j68eAODMw7/lFJavWCCiPMeqEHuOGx0YmoU=